Quote:
Originally Posted by mathewgk80
Hi all,
I have a string variable called userid and i want to encrypt the userid and store it into another variable using the stored procedure. Again i have to decrypt the encrypted value to the original string value using another stored procedure.
I am using sql server.
Please help me...
Thanks and regards,
Mathew
In SQL Server 2000, you have to create your own user-defined functions to encrypt the data or use external DLLs to encrypt the data. In SQL Server 2005, these functions and methods are available by default.
SQL Server 2005 provides the following mechanism of encryption in order to encrypt the data.
* ENCRYPTION by passphrase
* ENCRYPTION by symmetric keys
* ENCRYPTION by Asymmetric keys
* ENCRYPTION by certificates
for simplycity you can use ENCRYPTION by passphrase method
“ENCRYPTION by passphrase” is basically encrypting the data using a password. The data can be decrypted using the same password.
eg:
select EncryptByPassPhrase('key', 'abc' )
result encrypted value: 0x01000000674FB952B3F9D575EB4B9E7A22BEC4800F6310C7 F96CA821
select convert(varchar(100),DecryptByPassPhrase('key'
, 0x01000000011FFAE33EA305F8DE68453A1CE3425C3F663849 D02F21CE))
result decrypted value : abc