Ja, die generate Zeile habe ich aus einer anderen Verschlüsselung, welche auch läuft.
Folgender Code gibt :
"Zusätzliche Informationen: Im Byteindex 1 wurde ein ungültiges Byte gefunden."
aus:
Public Function XMLDateiSpeichern2()
Dim rd2 As New RijndaelManaged()
Dim md5 As New MD5CryptoServiceProvider()
Dim key2() As Byte = md5.ComputeHash(Encoding.UTF8.GetBytes("test"))
md5.Clear()
rd2.Key = key2
Dim iv2() As Byte = rd2.IV
Dim fs As New IO.FileStream("test.xml", IO.FileMode.Create)
Dim cs As New System.Security.Cryptography.CryptoStream(fs, _
rd2.CreateEncryptor(key2, iv2), _
System.Security.Cryptography.CryptoStreamMode.Write)
ds.WriteXml(cs)
cs.Close()
fs.Close()
End Function
Public Function XMLDateiLaden2()
Dim rd2 As New RijndaelManaged()
Dim md5 As New MD5CryptoServiceProvider()
Dim key2() As Byte = md5.ComputeHash(Encoding.UTF8.GetBytes("test"))
md5.Clear()
rd2.Key = key2
Dim iv2() As Byte = rd2.IV
Dim fs As New IO.FileStream("test.xml", IO.FileMode.Open)
Dim cs As New System.Security.Cryptography.CryptoStream(fs, _
rd2.CreateDecryptor(key2, iv2), _
System.Security.Cryptography.CryptoStreamMode.Read)
ds.ReadXml(cs, XmlReadMode.DiffGram)
cs.Close()
fs.Close()
dt = ds.Tables(0)
End Function Und hier kommt beim lesen:
Zusätzliche Informationen: Systemfehler.
Public Function XMLDateiSpeichern2()
Dim rij2 As System.Security.Cryptography.Rijndael = _
System.Security.Cryptography.Rijndael.Create()
Dim rd2 As New RijndaelManaged()
Dim md5 As New MD5CryptoServiceProvider()
Dim key2() As Byte = md5.ComputeHash(Encoding.UTF8.GetBytes("test"))
md5.Clear()
rd2.Key = key2
Dim iv2() As Byte = rd2.IV
Dim fs As New IO.FileStream("test.xml", IO.FileMode.Create)
Dim cs As New System.Security.Cryptography.CryptoStream(fs, _
rij2.CreateEncryptor(key2, iv2), _
System.Security.Cryptography.CryptoStreamMode.Write)
ds.WriteXml(cs)
cs.Close()
fs.Close()
End Function
Public Function XMLDateiLaden2()
Dim rij2 As System.Security.Cryptography.Rijndael = _
System.Security.Cryptography.Rijndael.Create()
Dim rd2 As New RijndaelManaged()
Dim md5 As New MD5CryptoServiceProvider()
Dim key2() As Byte = md5.ComputeHash(Encoding.UTF8.GetBytes("test"))
md5.Clear()
rd2.Key = key2
Dim iv2() As Byte = rd2.IV
Dim fs As New IO.FileStream("test.xml", IO.FileMode.Open)
Dim cs As New System.Security.Cryptography.CryptoStream(fs, _
rij2.CreateDecryptor(key2, iv2), _
System.Security.Cryptography.CryptoStreamMode.Read)
ds.ReadXml(cs, XmlReadMode.DiffGram)
cs.Close()
fs.Close()
dt = ds.Tables(0)
End Function Mehr fällt mir nicht mehr ein.
Erzeugt Dim rij2 As System.Security.Cryptography.Rijndael = _
System.Security.Cryptography.Rijndael.Create() auch wieder einen neuen Wert ? |