Can't decrypt an password that I need to decrypt.
Cerealistic opened this issue ยท 17 comments
What behaviour is observed?
So I have an AuthMe password, encrypted in my auths.db. I try to decrypt a password out of this string:
$SHA$d916d124f19a659c$809140c2fc05e72fde5d0d57973e85a1f800b3eda024c9ae7d5ae0fbd23584d0:127.0.0.1:1683666307921
What does this mean? How to I decrypt it?
Expected behaviour
I expected it to be normal sha256.
To Reproduce
- go to your auths.db
- try to decrypt the sha256.
Plugin list
Authme, EssentialsX.
Server Implementation
Standalone server (no proxy)
Database Implementation
SQLite
AuthMe Version
5.6
Error log (if applicable)
No response
Configuration
Default config.
Take a string, encrypt it with sha256. Did it match the hash in the DB? No? Try again. :)
@Cerealistic What do you want to achieve? Do you want to verify the password input with the hash for example for a website integration? Then we are likely looking at decoding/deserializing the structure. Plain hashing functions are unsafe (re: rainbow tables) that's why there a salt added. The salt is included in the output. See the first characters between the dollar sign.
This can then be used to generate the same hash and thereby verify the input is equal to the value in the database.
However, if you really meant decrypting (i.e. getting the original input from the hash), this is intentionally difficult by design. Password hashing is a standard practice where the hashing functions are one-way (simplified). You should not being able to see the original input (simplified). If your use case is that a user forgets his/her password, then you should override the old hash. For example: by generating temporarily, random, one-time only password or letting them register again using a new password.
Okay, I will change their password. But how would AuthMe know the hash's correlation to the password if its one-way?
If the input is the same, it will generate the same output. The salt is added to the input to make it more unique. Rainbow tables are an attack methodology that uses pre-generated input->output values. By adding random salt values to the input, this attack can be prevented.
My earlier post
@Cerealistic What do you want to achieve? [...] The salt is included in the output. See the first characters between the dollar sign.
[...]
BTW: .
means string concatenation, so it would be something like this in Pseudo-Code
sha256(concat(sha256(password_input), salt))