Convert SHA1 back to string

I have a user model in my application, and sha1 is used in my password field. I want when I get sha1 from the db to create a row again. How to do it?

+3
source share
5 answers

You cannot - SHA1 is a one-way hash. Given the output of SHA1 (X), it is impossible to get X (at least not without brute force search or a dictionary / rainbow table )

A very simple way to think about this is to imagine that I am giving you a set of three-digit numbers that you need to add, and you will tell me the last two digits of this amount. From these two digits I was not able to determine exactly which numbers you started from.

see also

The thought associated with MD5, these other questions may also enlighten you:

+10
source

You cannot - this is the point SHA1, MDB5, etc. Most of them are unidirectional hashes for security. If this can be undone, then anyone who has access to your database can get all the passwords. That would be bad.

.

+1

SHA - . , reverse ( ).

( , ).

0

, . ( ). , , , .

: , , "". ( ) SHA-1, , , . "" SHA-1, , - , , 1) ( , 24/7 , ​​), - - , () .

0

You cannot do this with SHA-1. But, considering what you need to do, you can try using AES. AES allows you to encrypt and decrypt.

0
source

Source: https://habr.com/ru/post/1767958/


All Articles