SQL Server 2005 hashbytes(‘sha1’,'code') alternative in MySQL

岁酱吖の 提交于 2019-12-11 03:13:59

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!