AES Verschlüsselung klappt nicht mit Umlauten



Hallo,

ich verschlüssele Dateien mit der Rijndael Methode und wenn ich eine
Datei verschlüssele und wieder entschlüssele sind alle Umlaute in der
Datei weg.

hier meine 2 Methoden:

Public Sub EncryptAES(ByVal sourcePath As String, ByVal destPath
As String)
Dim rd As New System.Security.Cryptography.RijndaelManaged
Dim rijndaelIvLength As Integer = 16
Dim md5 As New
System.Security.Cryptography.MD5CryptoServiceProvider
Dim key() As Byte =
md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(mCryptPassword))
Dim cXMLFile As New System.IO.StreamReader(sourcePath)
md5.Clear()

Dim encdata() As Byte =
Convert.FromBase64String(cXMLFile.ReadToEnd.ToString)
cXMLFile.Close()
Dim ms As New System.IO.MemoryStream(encdata)
Dim iv(15) As Byte

ms.Read(iv, 0, rijndaelIvLength)
rd.IV = iv
rd.Key = key

Dim cs As New System.Security.Cryptography.CryptoStream(ms,
rd.CreateDecryptor,
System.Security.Cryptography.CryptoStreamMode.Read)

Dim data(ms.Length - rijndaelIvLength) As Byte
Dim i As Integer = cs.Read(data, 0, data.Length)
Dim eXMLFile As New System.IO.StreamWriter(destPath)
eXMLFile.Write(System.Text.Encoding.UTF8.GetString(data, 0,
i))
eXMLFile.Close()
cs.Close()
rd.Clear()
End Sub

Public Sub CryptAES(ByVal sourcePath As String, ByVal destPath As
String)
Dim rd As New System.Security.Cryptography.RijndaelManaged()
Dim md5 As New
System.Security.Cryptography.MD5CryptoServiceProvider
Dim key() As Byte =
md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(mCryptPassword))
Dim eXMLFile As New System.IO.StreamReader(sourcePath)

md5.Clear()
rd.Key = key
rd.GenerateIV()

Dim iv() As Byte = rd.IV
Dim ms As New System.IO.MemoryStream

ms.Write(iv, 0, iv.Length)

Dim cs As New System.Security.Cryptography.CryptoStream(ms,
rd.CreateEncryptor,
System.Security.Cryptography.CryptoStreamMode.Write)
Dim data() As Byte =
System.Text.Encoding.UTF8.GetBytes(eXMLFile.ReadToEnd.ToString)
eXMLFile.Close()
cs.Write(data, 0, data.Length)
cs.FlushFinalBlock()

Dim encdata() As Byte = ms.ToArray()
Dim cXMLFile As New System.IO.StreamWriter(destPath)
cXMLFile.Write(Convert.ToBase64String(encdata))
cs.Close()
rd.Clear()
cXMLFile.Close()
End Sub

Hat jemand ne Idee woran dies liegen könnte?

.



Relevant Pages

  • Re: Text verschlüsseln
    ... Ohne den passenden Schlüssel (Key) hätte das erst ... Private TripleDes As New TripleDESCryptoServiceProvider ... Public Sub New(ByVal key As String) ... Dim SHA1 As New SHA1CryptoServiceProvider ...
    (microsoft.public.de.german.entwickler.dotnet.vb)
  • =?iso-8859-1?q?Re:_"Ausf=FChren_als"_in_C#_programmieren_(L=F6sung_f=FCr_.NET_V2.0)?=
    ... string Arguments = this.txtArguments.Text.Trim; ... ProcessStartInfo MyInfo = new ProcessStartInfo; ... // Set arguments with the filename: ... // Set username and domain of new start account: ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)
  • Probleme mit Key bei Triple DES Crypto
    ... Private key As New TripleDESCryptoServiceProvider() ... Der Einstieg in meine Mini-Demo ist die Funktion "PWDHandlingEncrypt", da wird ein String verschlüsselt und dann gleich wieder entschlüsselt. ... Dim ms As New MemoryStream ...
    (microsoft.public.de.german.entwickler.dotnet.vb)
  • Re: XSLT mit VB.NET?
    ... Function transform(ByVal XML As String, ByVal XSL As String) As String ... Dim XSLT As New XslTransform ...
    (microsoft.public.de.german.entwickler.dotnet.vb)
  • Re: Aus einem Thread in den GUI Thread schreiben
    ... Dim Qu As New Queue ... ByVal text As String, ByVal key As String) As TreeNode ... Dim deleg As New delAddNode ... ByVal key As String) As myTreeNodeClass ...
    (microsoft.public.de.german.entwickler.dotnet.vb)