DES加密、解密
Dim sText As String = "123456"
Dim sKey As String = "MoMoMoMo"
Dim sIV As String = "oMoMoMoM"
Dim bKey() As Byte = System.Text.Encoding.UTF8.GetBytes(sKey)
Dim bIV() As Byte = System.Text.Encoding.UTF8.GetBytes(sIV)
Dim oMemoryStream As New IO.MemoryStream
Dim oTest As Cryptography.DESCryptoServiceProvider = New Cryptography.DESCryptoServiceProvider
oTest.Key = bKey
oTest.IV = bIV
Dim oWriteCryptoStream As New Cryptography.CryptoStream(oMemoryStream, oTest.CreateEncryptor, Cryptography.CryptoStreamMode.Write)
Dim oStreamWriter As New IO.StreamWriter(oWriteCryptoStream)
oStreamWriter.WriteLine(sText)
oStreamWriter.Close()
oWriteCryptoStream.Close()
Dim oBuffer() As Byte = oMemoryStream.ToArray
oMemoryStream.Close()
Dim oMemoryStream1 As New IO.MemoryStream(oBuffer)
Dim sKey1 As String = "MoMoMoMo"
Dim sIV2 As String = "oMoMoMoM"
Dim bKey1() As Byte = System.Text.Encoding.UTF8.GetBytes(sKey1)
Dim bIV1() As Byte = System.Text.Encoding.UTF8.GetBytes(sIV2)
Dim oTest1 As Cryptography.DESCryptoServiceProvider = New Cryptography.DESCryptoServiceProvider
oTest1.Key = bKey1
oTest1.IV = bIV1
Dim oReadCryptoStream As New Cryptography.CryptoStream(oMemoryStream1, oTest1.CreateDecryptor, Cryptography.CryptoStreamMode.Read)
Dim oStreamReader As New IO.StreamReader(oReadCryptoStream)
Dim sTestValue As String = oStreamReader.ReadLine \\原文