Connect with Peer Bloggers

Get your Bloggers ID and network with best bloggers around the world.

15

Insert an md5 password in mssql

Czetsuya
czetsuya's tech ― To md5 a string in mssql we execute this query:select HASHBYTES('MD5', 'password')//But this has a problem because it returns a VarBinary data type which is a garbled text. So it should be converted first to NVarchar:SELECT CONVERT(NVARCHAR(32),HashBytes('MD5', 'password'),2)//To insert in the databaseinsert into Users (username, password) values ('user', (SELECT CONVERT(NVARCHAR(32),HashBytes('MD5', 'password'),2)))

Voted by 1 User



What would you say?

Be the first to comment on this blog post! Sign in or Create an account.