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.
我需要在我们的Sql Server 2000数据库中散列(MD5)所有密码。我可以很容易地生成一个C#/ VB.NET程序来转换(哈希)所有密码,但我想知道(更多的是我的教育而不是真正迫切的需要),如果有可能直接在T-SQL中计算MD5哈希。感谢任何愿意回答的人。
6 个解决方案
#1
4
It is using this code, but it is not native to the language.
它正在使用此代码,但它不是该语言的原生代码。
http://www.codeproject.com/KB/database/xp_md5.aspx
http://www.codeproject.com/KB/database/xp_md5.aspx
#2
7
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).
在2005年及以后,您可以调用HashBytes()函数。在2000年,最接近的是pwdencrypt / pwdcompare,尽管这些函数有自己的缺陷(阅读链接的评论)。
#3
2
No, there is no native TSQL command to generate MD5 hash's in SQL Server 2000.
不,在SQL Server 2000中没有生成MD5哈希的本机TSQL命令。
In 2005 and above you can use the HashBytes
function: http://msdn.microsoft.com/en-us/library/ms174415.aspx
在2005年及以上,您可以使用HashBytes函数:http://msdn.microsoft.com/en-us/library/ms174415.aspx
#4
1
Please see below example/solution using 2008
请参阅下面的示例/解决方案使用2008
DECLARE @HashThis nvarchar(4000);
SELECT @HashThis = CONVERT(nvarchar(4000),'dslfdkjLK85kldhnv$n000#knf');
SELECT HashBytes('md5', @HashThis);
GO
#5
0
There is nothing magical about md5, you can implement it as a pure tsql function if you want to. I'm not sure it would be fun in tsql, but there should be nothing preventing you from doing so :)
关于md5没有什么神奇之处,如果你愿意的话,你可以把它作为一个纯粹的tsql函数来实现。我不确定它在tsql中会很有趣,但应该没有什么能阻止你这样做:)
#6
-1
Just for the record:
仅供记录:
UPDATE T_WHATEVER_YOUR_TABLE_NAME_IS
SET PREFIX_Hash = LOWER(SUBSTRING(master.dbo.fn_varbintohexstr(HashBytes('MD5', LOWER('a-string-with-utf8-encoded-international-text'))), 3, 32) )
#1
4
It is using this code, but it is not native to the language.
它正在使用此代码,但它不是该语言的原生代码。
http://www.codeproject.com/KB/database/xp_md5.aspx
http://www.codeproject.com/KB/database/xp_md5.aspx
#2
7
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).
在2005年及以后,您可以调用HashBytes()函数。在2000年,最接近的是pwdencrypt / pwdcompare,尽管这些函数有自己的缺陷(阅读链接的评论)。
#3
2
No, there is no native TSQL command to generate MD5 hash's in SQL Server 2000.
不,在SQL Server 2000中没有生成MD5哈希的本机TSQL命令。
In 2005 and above you can use the HashBytes
function: http://msdn.microsoft.com/en-us/library/ms174415.aspx
在2005年及以上,您可以使用HashBytes函数:http://msdn.microsoft.com/en-us/library/ms174415.aspx
#4
1
Please see below example/solution using 2008
请参阅下面的示例/解决方案使用2008
DECLARE @HashThis nvarchar(4000);
SELECT @HashThis = CONVERT(nvarchar(4000),'dslfdkjLK85kldhnv$n000#knf');
SELECT HashBytes('md5', @HashThis);
GO
#5
0
There is nothing magical about md5, you can implement it as a pure tsql function if you want to. I'm not sure it would be fun in tsql, but there should be nothing preventing you from doing so :)
关于md5没有什么神奇之处,如果你愿意的话,你可以把它作为一个纯粹的tsql函数来实现。我不确定它在tsql中会很有趣,但应该没有什么能阻止你这样做:)
#6
-1
Just for the record:
仅供记录:
UPDATE T_WHATEVER_YOUR_TABLE_NAME_IS
SET PREFIX_Hash = LOWER(SUBSTRING(master.dbo.fn_varbintohexstr(HashBytes('MD5', LOWER('a-string-with-utf8-encoded-international-text'))), 3, 32) )