我在java中使用AES/CBC/PKCS5Padding密码实例进行AES加密和解密如何在java中使用上面加密的黑莓来解密数据.
使用黑莓手机使用AES/CBC/PKCS5Padding解密数据
谢谢Bapi
我建议使用BlackBerry API(Bouncy Castle可以工作,但为什么会复杂化?).
使用net.rim.crypto包 - 您使用所有对称加密,因此您只需要在设备上运行标准RIM签名密钥(20美元和2-3天即可获得) - 同时您可以执行所有操作用模拟器.
基本上你需要创建一个PKCS5UnformatterEngine,它包装一个封装AESDecryptorEngine的CBCDecryptorEngine.可能会将所有内容都包装在BlockDecryptor中,以便您可以像在InputStream中一样处理.喜欢的东西(自从我完成这个以来已经有一段时间了,所以它可能不会像写的那样100%工作):
InputStream encryptedInput; // if you have a byte[] of data, use a ByteArrayInputStream
AESKey key = new AESKey(<your key data as a byte[]>)
InitializationVector iv = new InitializationVector(<your iv data as a byte[]>) // of course you need to know your IV since you're doing CBC encryption
BlockDecryptor decryptor = new BlockDecryptor(
new PKCS5UnformatterEngine(
new CBCDecryptorEngine(
new AESDecryptorEngine(key),
iv
)
)
);
// then decryptor acts as an InputStream which gives you your decrypted, unpacked data
decryptor.read(buffer); // buffer will contain decrypted, unpacked data
Run Code Online (Sandbox Code Playgroud)