Decrypts data previously encrypted with xp_des3_encrypt
algorithm.
Syntax
xp_des3_decrypt { encrypted_text ,
password, variable1 OUTPUT [, variable2 OUTPUT , variable3 OUTPUT
...] }
Arguments
encrypted_text
VARCHAR or VARBINARY. Text previously encrypted with xp_des3_encrypt
function.
password
VARCHAR. Your hard password. Exactly the same that is used for
encryption.
variable1 OUTPUT [, variable2 OUTPUT , variable3 OUTPUT ...]
Variables to hold the decrypted information. The order of the variables
should be the same with the order of variables given to the encryption function.
Remark
If you specify the wrong password the decryption will succeed but clear_text
will probably hold some garbage. You are not able to find out if the password was
wrong or correct.
Permissions
Execute permissions default to the public role.
Return Code Value
0 - success, or Error code
if failed.
Example
declare @encrypted varchar(8000)
declare @return_code int
exec xp_des3_encrypt 'clear','MyPassword', @encrypted OUTPUT
exec @return_code = xp_des3_decrypt @encrypted ,'MyPassword', @encrypted OUTPUT
if @return_code != 0 or @encrypted != 'clear' or @encrypted IS NULL
begin
raiserror ('des3 encryption failed!',16,10)
end
|
|