Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9072023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:04:09+00:00 2026-06-16T18:04:09+00:00

I need to implement RSA algorithm using ECB (Electronic Code Book) as a school

  • 0

I need to implement RSA algorithm using ECB (Electronic Code Book) as a school assignment. I know that ECB is bad and I should never use such thing in real life, but I have no other option here (we will eventually turn it to CBC and then move forward to AES, but at the moment I need to use ECB).

I’ve stumbled upon an issue with chaining the encrypted blocks: let’s say I have a key of size 256 bits, and as a result I set each block size to be have 256 bits (block size = key size). I also make sure to pad the last block in case its size is smaller. The problem is that the encrypted block result size varies, so I don’t know how to chain the result, so that when I decrypt the data I would know exactly when a block starts and when a block ends. What is the common thing to do in such event? I thought about putting some kind of delimiter between each block, but I think it’s a lousy solution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T18:04:11+00:00Added an answer on June 16, 2026 at 6:04 pm

    RSA uses internal padding, so you don’t need to pad the input. RSA encryption can normally be performed in two different padding modes: OAEP and PKCS#1.5 padding. Both add substantial padding to each block. This is different from e.g. AES padding, where the padding is only performed on the last block to be encrypted. Also different is that the security of RSA heavily relies on the padding, so it must be performed.

    Now, because each block is padded, obviously the plain text that fits into the block is less then the key size (the size of the modulus). In other words, the block size is smaller than the key size. In the case of PKCS#1.5 it is 11 bytes less than the key size (if this is on a byte boundary at least). Keeping to a slightly higher (say up to 19 bytes) block size would be better regarding security though, 8 bytes of the padding should be (secure) random bytes.

    With Java you can actually ask the block size from the Cipher object, and for RSA it will correctly subtract the overhead from the key size. Otherwise you will have to calculate it yourself. As said, you don’t require padding of the last block, the block padding will fill the last block for you.

    Note that the RSA PKCS#1 specifications are a free download. So you can do the calculations yourself for the (tougher) OAEP padding. For your particular assignment I would keep to 1.5 padding though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to implement RSA algorithm in Java. I've found the best solution using
I need to implement portable code, but I do not know how to deal
I need to implement RSA encryption/decryption using C# I have a private key with
I have a private key and exponent, i need to implement RSA encryption of
I want to implement a RSA algorithm to encrypt an image ( byte[] ).
I need to implement a method that concatenates different characters into a char* without
I need to implement adwhirl ad in my iphone app.I don't know how ı
i have big decision tree with many Yes/No questions. i need implement some code
I'm learning threads yet, but don't know much things. I see that I need
I need to implement a recursive function that returns 1 if the number is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.