xp_aes_decrypt
Decrypts data previously encrypted with xp_aes_encrypt
function
Syntax
xp_aes_encrypt { encrypted_text , key, variable1
OUTPUT [, variable2 OUTPUT , variable3 OUTPUT ...] }
Arguments
encrypted_text
VARCHAR or VARBINARY. Text previously encrypted with xp_aes_encrypt
function.
key
VARCHAR. The key is represented by a string which consists of characters from 0 to 9 and
A, B, C, D, E, F so called 'hexadecimal notation'. The valid lengths of the string are 32, 48 and 64 chars.
This evolves 128, 192 and 256 bit AES encryption. Example of 32 chars key - '076541A84BEF792A1234567890D98769'
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 the 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 Values
0 - success, or Error code if failed.
Example
declare @encrypted varchar (8000)
declare @return_code int
exec xp_aes_encrypt 'test','0123456789ABCDEF0123456789ABCDEF',@encrypted output
exec @return_code = xp_aes_decrypt @a,'0123456789ABCDEF0123456789ABCDEF',@encrypted output
if @return_code != 0
begin
raiserror ('AES encryption failed!',16,10)
end
|
|