This stored procedure is calculated MD5 value, can be used for password authentication encryption.
SQL Server's extended stored procedures (Extended Stored Procedure, abbreviated XP) are implemented by registering functions encapsulated in a. dll in the MSSQL database.
this. dll should follow the rules provided by m$ and connect to the library files for MSSQL. Because of C + + Builder the MSSQL library file OPENDS60. LIB is rather old,
This article provides a new version of OPENDS60. LIB library file, which supports the MSSQL version 2000.
--------------------------------------------------------------------------------
"Installation Method"
① registers a stored procedure by executing an SQL statement:
Open the Master database, and then execute the following SQL statement
EXEC sp_addextendedproc ' xp_md5 ', ' D:\pathname\xp_md5.dll '
If the registered file does not contain a path, only the filename, MSSQL will find this. dll in this folder.
C:\Program Files\Microsoft SQL Server\mssql\binn
② creates a MD5 function to support a SELECT statement fn_md5
Open the user database that you want to execute this stored procedure, and execute the following SQL:
CREATE FUNCTION fn_md5 (@string VARCHAR(8000))
RETURNS CHAR(32) AS
BEGIN
DECLARE @hash CHAR(32)
EXEC master.dbo.xp_md5 @string, @hash OUTPUT
RETURN @hash
END
"Use Method"
① is executed directly, because the XP_MD5 is in the master database, so the front must have master.
EXEC master.dbo.xp_md5 ' Hello world! '
② supports the SELECT statement through FN_MD5, which is in the database currently used by the user.
SELECT dbo.fn_md5 (' Hello world! ')
"Program description"
XP_MD5.BPR stored Procedure C + + Builder 6.0 engineering files
OPENDS60. LIB because of C + + Builder file is older, support MSSQL 7, this program brought a OPENDS60. LIB file, support MSSQL 2000
Md5.h Christophe Devine The original, without making any changes.
Md5.cpp Christophe Devine The original, without making any changes.
Xp_md5_main.cpp stored Procedure main program file, modified according to Vic Mackey's stored procedure
When you create a project, you can use the DLL Wizard to generate it, and without special requirements, stored procedure functions need to be in the specified format:
__declspec (dllexport) srvretcode winapi Xpname (srv_proc* psrvproc)
Where Xpname is the name of the stored procedure, and the other is the specified format can not be changed
Additionally, the stored procedure. dll file must contain this function:
__declspec (dllexport) ULONG WINAPI __GetXpVersion ()
Detailed content please download the source program to see, relatively simple.
For a description of the function, see here at MSDN:
Http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odssql/ods_6_ref_02_8k2t.asp