java - bounce castle aes encryption in blackberry -


can please 1 explain aes/cbc/pkcs5padding encryption , decryption using bounce

castle tried hardly myself not getting success.

on net not getting tutorial regarding

i assume asking bouncy castle lightweight api part of j2me release. specifications page, there example of how use api. i've updated match latest api. (note haven't tried run this.)

blockcipher engine = new aesengine(); bufferedblockcipher cipher = new paddedbufferedblockcipher(new cbcblockcipher(engine));  byte[] key = keystring.getbytes(); byte[] input = inputstring.getbytes();  cipher.init(true, new parameterswithiv(new keyparameter(key), ivbytes));  byte[] ciphertext = new byte[cipher.getoutputsize(input.length)];  int outputlen = cipher.processbytes(input, 0, input.length, ciphertext, 0); try {     cipher.dofinal(ciphertext, outputlen); } catch (cryptoexception ce) {     system.err.println(ce);     system.exit(1); } 

note default padding mode of paddedbufferedblockcipher pkcs7/pkcs5.

decryption similar, call cipher.init(false, ...) , pass in ciphertext processbytes.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -