问题描述
我使用AES / CBC / PKCS5Padding AES加密和解密在Java密码实例
我怎样才能解密使用BlackBerry通过上述在java中加密的数据。
I am using AES/CBC/PKCS5Padding cipher instance for AES encryption and decryption in javaHow can I decrypt the data using blackberry encrypted by above in java.
与使用AES / CBC / PKCS5Padding解密黑莓数据
decrypting data with AES/CBC/PKCS5Padding using blackberry
谢谢
BAPI
ThanksBapi
推荐答案
我建议使用黑莓API(充气城堡的工作,但为什么事情复杂化?)。
I recommend using the BlackBerry API (Bouncy Castle will work, but why complicate things?).
使用的net.rim.crypto包 - 你正在使用的所有对称加密,所以你只需要标准的在设备上运行($ 20 2-3天拿到) - 在此期间你可以用模拟器一切
Use the net.rim.crypto package - you're using all symmetric encryption so you'll only need the standard RIM signing keys to run on a device ($20 and 2-3 days to get) - in the meantime you can do everything with the simulator.
基本上,你要创建一个封装了CBCDecryptorEngine包装了一个AESDecryptorEngine一个PKCS5UnformatterEngine。在BlockDecryptor也许换一切,所以你可以把是在InputStream的。喜欢的东西(它已经有一会儿,因为我已经做到了这一点,所以它可能无法正常工作,写100%):
Basically you'll want to create a PKCS5UnformatterEngine which wraps a CBCDecryptorEngine which wraps an AESDecryptorEngine. Probably wrap everything in a BlockDecryptor so you can treat is as in InputStream. Something like (and it's been a little while since I've done this, so it may not work 100% as written):
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
这篇关于解密使用黑莓的AES / CBC / PKCS5Padding数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!