English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

in a datasource that i have i made my own sql database and everything, i wana md5 the password comming in my insert statement is as follows

InsertCommand="INSERT INTO [MEMBERS] ([memUser], [memFirst], [memLast], [memMiddle], [memAdd], [memPhone], [memCity], [memPass], [memPostal]) VALUES (@memUser, @memFirst, @memLast, @memMiddle, @memAdd, @memPhone, @memCity, md5(@memPass), @memPostal)"


notice md5(@memPass)

thats not right i was wondering if some one could give me the proper syntax thanks

2007-04-26 18:32:41 · 1 answers · asked by Anonymous in Computers & Internet Programming & Design

1 answers

Check out the article I've listed in Code Project.

I don't think SQL comes with a function called md5.

To make a function, you need to do the following.

1. Place the xp_md5.dll in the c:\program files\Microsoft SQL Server\MSSQL\Binn.

2. Switch to the master database and execute the following code.
EXEC sp_addextendedproc 'xp_md5', 'xp_md5.dll'

3. Now you need to create a function that calls the xp_md5 extended stored procedure, by running the following in your databse.

CREATE FUNCTION [dbo].[fn_md5] (@data TEXT)
RETURNS CHAR(32) AS
BEGIN
DECLARE @hash CHAR(32)
EXEC master.dbo.xp_md5 @data, -1, @hash OUTPUT
RETURN @hash
END

4. Now you need to adjust your call to md5 just a little. Like so
InsertCommand="INSERT INTO [MEMBERS] ([memUser], [memFirst], [memLast], [memMiddle], [memAdd], [memPhone], [memCity], [memPass], [memPostal]) VALUES (@memUser, @memFirst, @memLast, @memMiddle, @memAdd, @memPhone, @memCity, dbo.fn_md5(@memPass), @memPostal)"

2007-04-26 18:47:09 · answer #1 · answered by Michael M 6 · 0 0

fedest.com, questions and answers