Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to calculate MD5 hash directly in T-SQL language?

I need to hash (MD5) all the password in our Sql Server 2000 database. I can easily generate a C#/VB.NET program to convert (hash) all the passwords, but I was wondering (more for my education than for a real compelling need) if it was possible to calculate MD5 hash directly in T-SQL.
Thanks to anyone who will answer.

like image 464
M.Turrini Avatar asked May 26 '09 13:05

M.Turrini


3 Answers

In 2005 and later, you can call the HashBytes() function. In 2000, the closest thing is pwdencrypt/pwdcompare, though those functions have their own pitfalls (read the comments of the link).

like image 93
Joel Coehoorn Avatar answered Oct 12 '22 09:10

Joel Coehoorn


It is using this code, but it is not native to the language.

http://www.codeproject.com/KB/database/xp_md5.aspx

like image 41
Daniel A. White Avatar answered Oct 12 '22 07:10

Daniel A. White


No, there is no native TSQL command to generate MD5 hash's in SQL Server 2000.

In 2005 and above you can use the HashBytes function: http://msdn.microsoft.com/en-us/library/ms174415.aspx

like image 27
samjudson Avatar answered Oct 12 '22 08:10

samjudson