问题
Hi i have several passwords encrypted in this way:
hashbytes(‘sha1’,'password')
Using SQL Server 2005, we are planing a migration to MySQL.
There is a hash function equivalent in MySQL or PHP.
Because i use a standard SHA1 algorithm and results are different that the ones i have using SQL Server algorithm.
回答1:
I found out that php uses ascii encoding, so in order to get the same results in sql server management studio for example, use a varchar(8000) as @input.
回答2:
MySQL has a SHA1
function:
mysql> SELECT SHA1('password');
+------------------------------------------+
| SHA1('password') |
+------------------------------------------+
| 5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8 |
+------------------------------------------+
What does the equivalent SQL Server function produce?
来源:https://stackoverflow.com/questions/4892462/sql-server-2005-hashbytes-sha1-code-alternative-in-mysql