3DES Key
Posted: Wed Jan 18, 2017 11:58 pm
I have to encrypt data with 3DES algo in my applet. I also need to decrypt the data in my host application. And the key for 3DES should be 24 bytes, anyone can figure out how to extend the 16 byte key to 24 byte key?
Here is my code
Here is my code
Code: Select all
cipherDES = Cipher.getInstance(Cipher.ALG_DES_CBC_ISO9797_M1, false);
randomData = RandomData.getInstance(RandomData.ALG_SECURE_RANDOM);
sessionKey = (DESKey) KeyBuilder.buildKey(KeyBuilder.TYPE_DES,KeyBuilder.LENGTH_DES3_2KEY, false);
randomData.generateData(sessionKeyBytes, (short) 0, (short) 15);sessionKey.setKey(sessionKeyBytes, (short) 0);
cipherDES.init(sessionKey, Cipher.MODE_ENCRYPT);