create table accounts (acntno int, crdtno varbinary(255))
create masterkey
--Using keys
create table accounts (acntno int, crdtno varbinary(255))
create master key encryption by password = 'password@123'
--new conceptin 2005-> certificates
create certificate crt1 with subject = 'hello'
--triple_des is 128bit algorithm
create symmetric key smkey1 with algorithm = triple_des encryption by certificate crt1
open symmetric key smkey1 decryption by certificate crt1
--encrypting data
declare @key uniqueidentifier
set @key = key_guid('smkey1')
insert into accounts values (1,encryptbykey(@key,'111-222-333-444'))
select * from accounts
--result=1,0x00F3C7FAE2A53249B54BE331BC22E380010000006A5E0908875E3FBC7C921C72551097EF4BADF78E84F315C022DB5326D6819D9A
--To see the data
select acntno,cast(decryptbykey(crdtno) as varchar(255)) from accounts
close symmetric key smkey1

