[CLOSED] Aes Encryption fails
-
why does this function fails, with CipherMode.OFB where as it works with CipherMode.ECB
Public Function EncryptAES(sIn As String, sKey As String) As String
Dim AES As New RijndaelManaged()
Dim ahashMD5 As New MD5CryptoServiceProvider()
AES.Key = ahashMD5.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(sKey))
AES.Mode = CipherMode.OFB
Dim AESEncrypt As ICryptoTransform = AES.CreateEncryptor()
Dim aBuffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(sIn)
Return Convert.ToBase64String(AESEncrypt.TransformFinalBlock(aBuffer, 0, aBuffer.Length))
End FunctionError Message : Specified cipher mode is not valid for this algorithm.
Regards, Vishal
-
why does this function fails, with CipherMode.OFB where as it works with CipherMode.ECB
Public Function EncryptAES(sIn As String, sKey As String) As String
Dim AES As New RijndaelManaged()
Dim ahashMD5 As New MD5CryptoServiceProvider()
AES.Key = ahashMD5.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(sKey))
AES.Mode = CipherMode.OFB
Dim AESEncrypt As ICryptoTransform = AES.CreateEncryptor()
Dim aBuffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(sIn)
Return Convert.ToBase64String(AESEncrypt.TransformFinalBlock(aBuffer, 0, aBuffer.Length))
End FunctionError Message : Specified cipher mode is not valid for this algorithm.
Regards, Vishal
Because the
RijndaelManaged
class doesn't support theOFB
cipher mode. It only supportsCBC
,ECB
andCFB
.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Because the
RijndaelManaged
class doesn't support theOFB
cipher mode. It only supportsCBC
,ECB
andCFB
.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
sir can you please guide which aes module for asp.net contains OFB cipher mode
Regards, Vishal
There doesn't appear to be anything built-in to .NET which supports using AES in OFB mode. You'll need to find a third-party library to support that.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
There doesn't appear to be anything built-in to .NET which supports using AES in OFB mode. You'll need to find a third-party library to support that.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer