Possible Duplicate:
Java AES Encrypt Entire String
我已陷入一个小问题。 出于某种原因,我可以采用我对其加以加密的同样方法,对一些护卫进行加密。 例如,使用该编码进行加密的Im:
SecretKeySpec key = new SecretKeySpec(salt.getBytes(), "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding", "SunJCE");
cipher.init(Cipher.DECRYPT_MODE, key);
String result = new String(cipher.doFinal(message));
System.out.println("Decrypted:" + result);
Anyway, when the salt is "1231231231231231" and the message that im trying to decrypt is "read". I get this error:
Exception in thread "main" javax.crypto.BadPaddingException: Given final block not properly padded
But the encryptor (which works the same way) says the encrypted value is
I¡?Þd↨Ú#à, 7êLO*
我如何确定这一点,或避免用户对此类描述的投入? Thansk