I want to encrypt and decrypt a file containing usernames and passwords. Since this file will be accessed to check if the username and password entered is correct, I’m sure that generating a different key each time the program starts will not work, since it will decrypt the file incorrectly (because it was previously encrypted with a different key). Is there a better way of doing what I want to do? I want to just provide a static key here:
cipher.init(Cipher.ENCRYPT_MODE, KEY_HERE);
But I’m not sure what the data type for that parameter is, if ever that would work. I appreciate any help.
You don’t want to use a reversible algorithm for passwords. Read this excellent article on the subject