Crypt and decrypt password

I am not sure what your specific goal is–maybe you have a very good reason for the need of decrypting a password–but a fundamental rule of IT security is to never, ever store passwords in a decryptable way. If an attacker gets hold of the encryption key, they will be able to read all passwords from that database instantly.

Passwords should always be stored as a hash. Hash functions are one-way functions - it is easy and fast to get a hash value from a clear text but next to impossible to get the clear text back from the hash.

When it comes to validating a password entered by a user, the entered password is run through the same hash function, and if the two hashes are identical, the user is successfully authenticated.

Apologies if you know that already–as I already wrote, I don’t know the reasons behind storing the password encrypted rather than hashed–, but this thread will be read by many people, and I think it is important that readers know that the standard way of securely storing passwords is using a cryptographic hash function. (And ideally with some salt and pepper on top.)

3 Likes