I have a table called #encryption
Create Table #encryption
(EmployeeIDEncrypted varchar(100),EmployeePartialID varchar(10))
and I have a function which uses the EmployeeIDEncrypted value and EmployeePartialID as parameters and returns back the decrypted value.
When i use the function like thisselect DecryptEmplID(EmployeeIDEncrypted,EmployeePartialID)
i am getting the following error.
Msg 6522, Level 16, State 2, Line 2
A .NET Framework error occurred during execution of user-defined routine or aggregate "fn_COM_DecryptEmplID":
SSystem.Security.Cryptography.CryptographicException: Padding is invalid and cannot be removed.
System.Security.Cryptography.CryptographicException:
at System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode paddingMode, Boolean fLast)
at System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount)
at System.Security.Cryptography.CryptoStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at Direct.Common.Cryptography.Encryption.Decrypt(String encryptedText, String password, String saltValue)
at Direct.Common.SQLCryptography.CryptoManager.DecryptValue(String valueToDecrypt, String password)
.
What am i doing wrong..
Thanks
gs