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?
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:
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.
.
SHA - . , reverse ( ).
reverse
( , ).
, . ( ). , , , .
: , , "". ( ) SHA-1, , , . "" SHA-1, , - , , 1) ( , 24/7 , ), - - , () .
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.
Source: https://habr.com/ru/post/1767958/More articles:WPF Rendering Performance Measurement - performanceHow to draw a box, a rectangle in a C # application - c #Convert 4 char string to int32 - c #Running a batch file remotely using Hudson - build-automationMocking / Stubbing application controller method using Mocha (using Shoulda, Rails 3) - ruby-on-railsDecode sha1 string to regular string - iphoneWCF Security in Internet Scenarios - securityStrict string in byte encoding in C # - c #Force update NSFetchedResultsController when changing the number of associations - iphoneHow to make VS Unit Test show an error message from exceptions other than UnitTestAssertException? - exceptionAll Articles