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 8512323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:14:52+00:00 2026-06-11T04:14:52+00:00

I want to decrpyt the encrypted message digest. i hav this code in my

  • 0

I want to decrpyt the encrypted message digest. i hav this code in my java program:

 String bobSignedMsg = SignedMsg;

    //At the receiving end, Bob extracts the msg 
    // length, the msg text, and the digital
    // signature from the signed msg.
    //Get the message length.
    int MsgLen = Integer.parseInt(bobSignedMsg.trim().substring(bobSignedMsg.length()-6));
    System.out.println(
               "\n12. Bob's calculated msg len: "
                                 + MsgLen);

    //Get the message text.
    String bobMsgText = bobSignedMsg.substring(
                                 0,MsgLen);
    System.out.println(
               "\n13. Bob's extracted msg text: "
                             + bobMsgText);

    //Bob knows that everything following the msg
    // text except for the four characters at the
    // end that indicate the message length is
    // the encoded and encrypted version of the
    // extended digital signature.  He extracts
    // it.
     String bobExtractedSignature =
          bobSignedMsg.substring(
            MsgLen,bobSignedMsg.length() - 6);
    System.out.println(
        "\n14. Bob's extracted extended digital "
                    + "signature: " 
                        + bobExtractedSignature);
    byte[] strtodecrypt=bobExtractedSignature.getBytes();

            byte[] decryptedCardNo = obj.rsaDecrypt(strtodecrypt,PbkeyPath);
         String decryptedform = obj.byteArrayToHexStr(decryptedCardNo);
         System.out.println("After Decryption: "+decryptedform);

In the above lines of code

byte[] decryptedCardNo = obj.rsaDecrypt(strtodecrypt,PbkeyPath);

calls the function:

public byte[] rsaDecrypt(byte[] sampleText,String pbkeypath) {
    PublicKey pubKey = null;
    try {
        pubKey = readKeyFromFile(pbkeypath);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    Cipher cipher = null;
    try {
        cipher = Cipher.getInstance("RSA");
    } catch (NoSuchAlgorithmException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (NoSuchPaddingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    try {
        cipher.init(Cipher.DECRYPT_MODE, pubKey);
    } catch (InvalidKeyException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    byte[] cipherData = null;
    try {
        cipherData = cipher.doFinal(sampleText);
        // cipherData = cipher.
    } catch (IllegalBlockSizeException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (BadPaddingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return cipherData;
}

But it gives the following error:

javax.crypto.IllegalBlockSizeException: Data must not be longer than 128 bytes
at com.sun.crypto.provider.RSACipher.a(DashoA13*..)
at com.sun.crypto.provider.RSACipher.engineDoFinal(DashoA13*..)
at javax.crypto.Cipher.doFinal(DashoA13*..)

I dont understand how to resolve the error for block size exception…..Please if anybody can help me with some ideas it wud be a great help in my project.

  • 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-11T04:14:53+00:00Added an answer on June 11, 2026 at 4:14 am

    Block ciphers, such as RSA, can only encrypt no more than blockSize bytes. If you want to encrypt an arbitrary large amount of data with the same key, you would split it to parts of blockSize and encrypt each block individually. The same applies to decryption.

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

Sidebar

Related Questions

I want to generate a link http://site/?code=xxxxxxxxxx Where xxxxxxxxxx is an encrypted string generated
i want to encrypt string in java and decrypt the same string in C#
I use some code to encrypt & decrypt string in C# but i want
I want to provide the user the ability to save personal data encrypted. This
I'm struggeling with code from this page: http://www.androidsnippets.com/encrypt-decrypt-between-android-and-php I want to send data from
I have a string that's encrypted using some crypto classes in Java (RSA/ECB/PKCS1Padding) and
want to know why String behaves like value type while using ==. String s1
Want to code a key pad for an calculator. What I want to make
I have a Credit Card Number in an XML Message and I want to
I want the code of Rijndael algorithm to encrypt any given text to store

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.