I'm using RSA encryption for converting simpletext to encrypted form.
my plain text is : hello
encrypted text : [B@d7eed7
Now, how to convert encrypted text into simple plain text i'm using following code
KeyPairGenerator keygenerator = KeyPairGenerator.getInstance("RSA");
SecureRandom random = SecureRandom.getInstance("SHA1PRNG", "SUN");
keygenerator.initialize(1024, random);
KeyPair keypair = keygenerator.generateKeyPair();
PrivateKey privateKey = keypair.getPrivate();
PublicKey publicKey = keypair.getPublic();
Cipher cipher = Cipher.getInstance("RSA");
String arrayStr = "[b@d7eed7";
byte ciphertext = arrayStr.getBytes();
cipher.init(Cipher.DECRYPT_MODE, privateKey);
byte[] cleartext1 = cipher.doFinal(ciphertext);
System.out.println("the decrypted cleartext is: " + new String(cleartext1));
i'm getting javax.crypto.BadPaddingException: Data must start with zero
need help !!
我只是查看了屏幕右侧的“相关”部分,然后将Java字符串转换为字节数组。
The problem is that [B@d7eed7
is not the encrypted text. It simply shows the type and the address of the byte array, not its contents.
For more information, see https://stackoverflow.com/a/5500020/367273
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.