. , , ,

,,,

COM- SQL Server — ,

, , , MD5 .

, , MD5 .

- MD5 , COM-, - MD5 ?

, COM-, Transact-SQL.

COM- ActiveX- CryptLib, http://www.activex.net.ru/activex/more.shtml#cryptlib regsvr32.

SQL Server, COM-:

 sp_OACreate

 sp_OAMethod

 sp_OADestroy

 sp_OAGetErrorInfo

, , sysadmin.

InsertMD5Value:

CREATE PROCEDURE dbo.InsertMD5Value

@Login Varchar(50), @Password Varchar(50)

AS

DECLARE @object int

DECLARE @hr Int

DECLARE @md5_hash varchar(255)

DECLARE @src varchar(255), @desc varchar(255)

SET NOCOUNT ON

EXEC @hr = sp_OACreate 'CryptLib.MD5', @object OUT

IF @hr <> 0

--

BEGIN

EXEC sp_OAGetErrorInfo @object, @src OUT, @desc OUT

SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc

GOTO END_FINAL

END

ELSE

BEGIN

EXEC @hr = sp_OAMethod @object, 'Crypt', @md5_hash OUT, @Password

IF @hr <> 0

GOTO CLEANUP

ELSE

PRINT @md5_hash

-- MD5 .

-- MD5 ,

--

-- @Login

-- INSERT INTO UsersReg (Login, Passwd) VALUES (@Login, @Password)

END

CLEANUP:

IF @hr <> 0

BEGIN

EXEC sp_OAGetErrorInfo @object, @src OUT, @desc OUT

SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc

END

BEGIN

EXEC @hr = sp_OADestroy @object

IF @hr <> 0

BEGIN

EXEC sp_OAGetErrorInfo @object, @src OUT, @desc OUT

SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc

END

END

END_FINAL:

RETURN

EXEC dbo.InsertMD5Value 'user1', 'test'


, , , MD5 . ,

 

 

 

! , , , .
. , :