E
E
Elnur Tazhimbetov2018-11-06 21:12:58
Java
Elnur Tazhimbetov, 2018-11-06 21:12:58

How long should string be for a key that is used in Java's built-in DES?

Cipher DES = Cipher.getInstance("DES");
byte[] decodedKey1 = java.util.Base64.getDecoder().decode(key);       
SecretKey originalKey1 = new SecretKeySpec(decodedKey1, 0, decodedKey1.length, "DES");
DES.init(Cipher.ENCRYPT_MODE, originalKey1);        
byte[] line = input.getBytes("UTF-8");
byte[] encryptedDes = DES.doFinal(line);

Here is such a simple code.
Why doesn't it accept a key with length 7 ? It seems that the key is usually 56 bits there, but is it 7 characters?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question