Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.security.InvalidKeyException: Invalid key length: 16 bytes :(

843811Oct 24 2007 — edited Oct 24 2007
Hello,
I know that this question is often asked but I have checked everything I found in this forum and did not find the solution to my problem.
I have to do a decryption with 3DES/ECB and I have got the following key : "A0A1A2A3A4A5A6A7A8A9AAABACADAEAF"

When I try the following code I get the "java.security.InvalidKeyException: Invalid key length: 16 bytes" exception
byte[] bDESKey = new byte[] {(byte) 0xA0, (byte) 0xA1, (byte) 0xA2, (byte) 0xA3, (byte) 0xA4, (byte) 0xA5, (byte) 0xA6, (byte) 0xA7,
                 (byte) 0xA8, (byte) 0xA9, (byte) 0xAA, (byte) 0xAB, (byte) 0xAC, (byte) 0xAD, (byte) 0xAE, (byte) 0xAF};

Security.addProvider(new Cryptix());
DESKey = new SecretKeySpec(bDESKey, "DES");
Cipher crypt = Cipher.getInstance("DES/ECB/NoPadding");
crypt.init(Cipher.ENCRYPT_MODE, DESKey);
The exception appear with the last line "crypt.init".

Does anyone of you know why the key I have received is not accepted?

Thanks in advance for your replies.

Remi.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 21 2007
Added on Oct 24 2007
4 comments
5,507 views