0

Is there a way to convert a string into a key so I can have the same encryption key for encoding/decoding? I do not mean using SecretKey btw.

Key symKey = KeyGenerator.getInstance(algorithm).generateKey(); 

I am using the DES algorithm btw

1 Answer 1

1

You probably mean a key derivation from a password. A popular approach is to use PBKDF2 in Java as discussed for example here. Don't forget to set the iteration count high to complicate brute-force attacks and set a random salt to prevent dictionary attacks.

A random salt is mandatory by now during user authentication, but it may also be used during encryption. It is just another public value that is added to the ciphertext like the IV for CBC mode.

Other alternatives would be bcrypt and scrypt which require additional libraries in Java.

Sign up to request clarification or add additional context in comments.

2 Comments

And what solution is this? You might want to post your own answer.
No i found a different way to use encryption without converting strings. I just have to use sql commands since this is just school test program

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.