I have to use AES encryption with OFB cipher mode , I use VB.NET 4.5 ,windows 8 and the following code:
Public Function DoEncryption(ByVal KeyArray() As Byte, ByVal IVArray() As Byte, ByVal Buffer As String) As Byte()
Dim encrypted() As Byte
Using a As Aes = Aes.Create()
a.Mode = CipherMode.OFB
Dim encryptor As ICryptoTransform
encryptor = a.CreateEncryptor(KeyArray, IVArray)
' Create the streams used for encryption.
Using msEncrypt As New MemoryStream()
Using csEncrypt As New CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write)
Using swEncrypt As New StreamWriter(csEncrypt)
'Write all data to the stream.
swEncrypt.Write(Buffer)
End Using
encrypted = msEncrypt.ToArray()
End Using
End Using
End Using
Return encrypted
End Function
I have an error "Invalid algorithm specified" at
swEncrypt.Write(Buffer)
any suggestions?