USE TEMPDB
GO
declare @hash varbinary (255)
CREATE TABLE tempdb..h (id_num int, hash varbinary (255))
SET @hash = pwdencrypt('123') -- encryption
INSERT INTO tempdb..h (id_num,hash) VALUES (1,@hash)
SET @hash = pwdencrypt('123')
INSERT INTO tempdb..h (id_num,hash) VALUES (2,@hash)
SELECT TOP 1 @hash = hash FROM tempdb..h WHERE id_num = 2
SELECT pwdcompare ('123', @hash) AS [Success of check] -- Comparison
SELECT * FROM tempdb..h
INSERT INTO tempdb..h (id_num,hash) 
VALUES (3,CONVERT(varbinary (255),
0x01002D60BA07FE612C8DE537DF3BFCFA49CD9968324481C1A8A8FE612C8DE537DF3BFCFA49CD9968324481C1A8A8))
SELECT TOP 1 @hash = hash FROM tempdb..h WHERE id_num = 3
SELECT pwdcompare ('123', @hash) AS [Success of check] -- Comparison
SELECT * FROM tempdb..h
DROP TABLE tempdb..h
GO

Results

(1 row(s) affected)
(1 row(s) affected)
Success of check ------------------- 1 (1 row(s) affected)
id_num hash ----------- ------------------------------------------------------ 1 0x01004A335DCEDB366D99F564D460B1965B146D6184E4E1025195 2 0x0100E11D573F359629B344990DCD3D53DE82CF8AD6BBA7B638B6 (2 row(s) affected)
(1 row(s) affected)
Success of check
-------------------
1
(1 row(s) affected)
id_num hash ----------- ------------------------------------------------------ 1 0x01004A335DCEDB366D99F564D460B1965B146D6184E4E1025195 2 0x0100E11D573F359629B344990DCD3D53DE82CF8AD6BBA7B638B6 3 0x01002D60BA07FE612C8DE537DF3BFCFA49CD9968324481C1A8A8FE612C8DE537DF3BFCFA49CD9968324481C1A8A8 (3 row(s) affected)
2009/04/21 10:43 2009/04/21 10:43

Trackback Address :: https://youngsam.net/trackback/324