S
Showjumper
I have solved my previous decryption problem wherein i was getting a
specified cast is not valid msg.
My new problem is htis: The password is not being decrypted. I am using
Rijndael. The code is from Pro ASP.NET 1.1. The string being returned looks
like 3B746F54E9D44721D6CE1337498FDB823B746F54E9D44721D6CE1337498FDB82
Thanks for any help Ashok
In my db access code:
If dr.Read() Then
encryptedData = CType(dr("Password"), Byte())
End If
Return s.DecryptToString(encryptedData,
CType(HttpContext.Current.Application("Key"), Rijndael))
The decyption function
Public Shared Function DecryptToString(ByVal dataToDecrypt As Byte(), ByVal
crypt As SymmetricAlgorithm) As String
Dim ms As MemoryStream = New MemoryStream
Dim cs As CryptoStream = New CryptoStream(ms, crypt.CreateDecryptor(),
CryptoStreamMode.Write)
cs.Write(dataToDecrypt, 0, dataToDecrypt.Length)
cs.FlushFinalBlock()
Dim r As BinaryReader = New BinaryReader(ms)
ms.Position = 0
Dim decryptedData As String = r.ReadString()
r.Close()
Return decryptedData
End Function
specified cast is not valid msg.
My new problem is htis: The password is not being decrypted. I am using
Rijndael. The code is from Pro ASP.NET 1.1. The string being returned looks
like 3B746F54E9D44721D6CE1337498FDB823B746F54E9D44721D6CE1337498FDB82
Thanks for any help Ashok
In my db access code:
If dr.Read() Then
encryptedData = CType(dr("Password"), Byte())
End If
Return s.DecryptToString(encryptedData,
CType(HttpContext.Current.Application("Key"), Rijndael))
The decyption function
Public Shared Function DecryptToString(ByVal dataToDecrypt As Byte(), ByVal
crypt As SymmetricAlgorithm) As String
Dim ms As MemoryStream = New MemoryStream
Dim cs As CryptoStream = New CryptoStream(ms, crypt.CreateDecryptor(),
CryptoStreamMode.Write)
cs.Write(dataToDecrypt, 0, dataToDecrypt.Length)
cs.FlushFinalBlock()
Dim r As BinaryReader = New BinaryReader(ms)
ms.Position = 0
Dim decryptedData As String = r.ReadString()
r.Close()
Return decryptedData
End Function