How to Decrypt MySQL Passwords

How can I decrypt MySQL passwords

If a proper encryption method was used, it's not going to be possible to easily retrieve them.

Just reset them with new passwords.

Edit: The string looks like it is using PASSWORD():

UPDATE user SET password = PASSWORD("newpassword");

How can I decrypt MySQL passwords since mysql 8.0.11

Passwords for authentication are stored in a way that's irrecoverable, it's a one-way hashing function that's applied. In this case it's SHA2.

There's no way to "unhash" this by design. The database entry contains just enough information to validate any given password, but not enough to tell you what the password is.

You can reset the password by disabling password checks and set a new password.

MySQL: decrypt password

The PASSWORD function performs encryption one-way so basically, there is no way to decrypt.

Decryption of password encrypted using PASSWORD() function of mysql

You should never store your passwords in a way that they can be decrypted. Instead just generate a new password.

Something like:

UPDATE users SET `password` = 'PASSWORD(someSuper.Safe123Password!)' WHERE `id` = USERID

How to decrypt password in mysql

You don't encrypt passwords, you hash them.

The point is, that you don't actually need the users password, you just need to know that they know it.

As an example, an absolutely terrible way to do that might be a simple count: e.g.

if the users password was 'horse123', you might store that as 8. Then you just count the letters in the password, and if it's 8, you know it's right.

That means that you never need to know the actual password.

Clearly that's awful, as there are many passwords with 8 characters! We need something with less 'collisions'.

Instead, we use one way hash functions. The most common way to do this is to use an MD5 hash. (it's not the best, but it's simple to explain). For how to actually do this, look at http://www.openwall.com/phpass/.

For the short and sweet version:

Get the users password, and do something like:

$pass = md5('somerandomtextthatyouknow'.$_POST['password']);

then, store that in your DB.

When they log in, you do the same again, and check that the hash in your DB.

This way, you never need to know the actual passwords, the passwords can be as long as you like, and if your database is stolen, the hashes are not useful to anyone (because we added in that random text).

So, now you understand that, read:

http://www.openwall.com/phpass/

and absolutely read up on SQL injection and SQL prepared statements, else this is all a bit pointless!



Related Topics



Leave a reply



Submit