|
Encrypts data with the given password by AES algorithm with 128 bit key. This
algorithm differs from xp_aes_encrypt.
xp_aes128_encrypt does not pad source variable with random data. Unilke
xp_aes_encrypt, it always produces the same output for the same input data. This
is very useful if you plan to use encrypted value as index or primary keys.
Syntax
xp_aes128_encrypt { variable1 [, variable2 , variable3 ...] , password,
encrypted_text OUTPUT
}
Arguments
variable1 [, variable2 , variable3 ...]
Variables which need to be encrypted
password
VARCHAR.Secure password
encrypted_text
VARCHAR or VARBINARY. Variable to hold the output.
Permissions
Execute permissions default to the public role.
Return Code Values
0 - success, or Error code
if failed. encrypted_text IS NOT NULL (success) or IS NULL (failure)
Example
declare @encrypted varchar(8000)
exec xp_aes128_encrypt 'clear','MyPassword', @encrypted OUTPUT
exec xp_aes128_decrypt @encrypted ,'MyPassword', @encrypted OUTPUT
if @encrypted != 'clear' or @encrypted IS NULL
begin
raiserror ('AES128 encryption failed!',16,10)
end |
|