URLEncode/URLDecode did not seem to make any difference. The decrypt error still happens. I also changed the db fields to nvarchar(100), with no luck.
Public Function GetCustomer(ByVal customerId As Integer) As CustomerInfo
Dim customerInfo As New CustomerInfo
Dim Encrypter As New IWebEncryption()
customerInfo = CType(CBO.FillObject(DataProvider.Instance().GetCustomer(customerId), GetType(CustomerInfo)), CustomerInfo)
'Decode the data before Decryption
customerInfo.AccountNo = HttpUtility.UrlDecode(customerInfo.AccountNo)
customerInfo.CID = HttpUtility.UrlDecode(customerInfo.CID)
customerInfo.ExpDate = HttpUtility.UrlDecode(customerInfo.ExpDate)
'Decrypt
customerInfo.AccountNo = Encrypter.DeCrypt(customerInfo.AccountNo, _key)
customerInfo.CID = Encrypter.DeCrypt(customerInfo.CID, _key)
customerInfo.ExpDate = Encrypter.DeCrypt(customerInfo.ExpDate, _key)
Return customerInfo
End Function
Public Function AddCustomer(ByVal objCustomer As CustomerInfo) As Integer
Dim Encrypter As New IWebEncryption()
'Encrypt Data
objCustomer.AccountNo = Encrypter.Encryption(objCustomer.AccountNo, _key)
objCustomer.CID = Encrypter.Encryption(objCustomer.CID, _key)
objCustomer.ExpDate = Encrypter.Encryption(objCustomer.ExpDate, _key)
'Encode the data before entry into the DB
objCustomer.AccountNo = HttpUtility.UrlEncode(objCustomer.AccountNo)
objCustomer.CID = HttpUtility.UrlEncode(objCustomer.CID)
objCustomer.ExpDate = HttpUtility.UrlEncode(objCustomer.ExpDate)
Return DataProvider.Instance().AddCustomer(objCustomer.OrderId, _
objCustomer.CustomerFirstName, _
objCustomer.CustomerLastName, _
objCustomer.AccountType, _
objCustomer.AccountNo, _
objCustomer.CID, _
objCustomer.ExpDate)
End Function