java - I have javax.crypto.BadPaddingException: RSA Cryptography -


I have a problem with RSA cryptography when the message is too long.

MySiffer:

  public static byte [] encrypt (byte [] datatype, publication of public) {try {system.out.println ( "Encrypt"); Cipher cipher = cipher Get Instances ("RSA / ECB / PKCS 1 Padding"); Cipher It (cipher NCRYPMOEEE, PubK); Byte [] encrypted = new byte [datatycript.lumb]]; System.out.println ("imagebight length:" + dataeticcript length); Byte [] TIP = new byte [53]; Byte [] temp2 = Faucet; Int x, y, z = 0; Int repeats = datatypecript.label/53; System.out.println ("Change:" + Repeats); {System.out.println ("change number:" + z) for (z = 0; z  

Main:

  public static void main (String petition []) {MsgAtoB_1 msg = new message Attobi_l ( New BigInteger (String.valueOf (System.currentTimeMillis ()), "Login"); Byte [] tab = MySerializer.serialize (msg); KeyPair key = Keys.generateKeyPair (); Byte [] crypt = MyCipher.encrypt (tab, key.getPublic ()); Byte [] Decrypt = MyEpper Decrypt (crypt, keygivivate ()); If (tab.equals) "System.out.println" ("yes it is work"); Else System.out.println ("Kuo OOOOOOOOO"); }  

Output:

  run encrypting Cvibait length encryption: 319 changes: 6 outstanding number: 0 iterative calculations using numbers: 1 Transformation No. 2 shift numbers: 3 change No. 4 order No. 5 Read in decrypt outsun.security.rsa.RSAPrivateCrtKeyImpl@fff5bef2 Imagebyte length: 319 changes: 6 change number: 0 javax.crypto.BadPaddingException: data start from scratch should Hi, the solution: using Java and RSA encrypt large data and decrypt 


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -