Calculates SHA1 hash of the given string accordingly to RFC
3174
Syntax
xp_sha1 variable1 [, variable2 , variable3 ...], @hash OUTPUT
Arguments
text
VARCHAR. Source text
hash
VARCHAR or VARBINARY. Variable that holds the hash value. It has
a constant
size of 40 chars or 20 bytes in the binary form.
Permissions
Execute permissions default to the public role.
Return Code Values
0 - success, or Error code if failed. hash IS NOT NULL (success) or IS NULL (failure)
Example
declare
@encrypted_password varchar(40)
-- Output result should not be less than
40 chars
declare @clear_password
varchar(16)
select @clear_password='abc'
exec xp_sha1
@clear_password,@encrypted_password OUTPUT
select @encrypted_password
|
The output should be :
----------------------------------------
A9993E364706816ABA3E25717850C26C9CD0D89D
|