How to conditionally check Symmetric Encryption with AES_256 algorithm data with variable data

54 Views Asked by At

I'm using AES_256 algorithm

SELECT count(1)
from [dbo].[EmployeeMaster]
where [UserName]=EncryptByKey (Key_GUID('Symmetrickey'),'Username')

Here a value with matched case, but result is '0'

with this code i'll get result. but i have huge amount of data for comparing this

SELECT count(1)
from [dbo].[EmployeeMaster]
where CONVERT(nvarchar, DecryptByKey([UserName]))='Username'

Can anyone suggest me a better way?

0

There are 0 best solutions below