DESCryptoServiceProvider.CreateDecryptor : DESCryptoServiceProvider « System.Security.Cryptography « VB.Net by API






DESCryptoServiceProvider.CreateDecryptor

  
 

Imports System.Security
Imports System.Security.Cryptography
Imports System.Text
Imports System.IO


Public Class Tester
    Public Shared Sub Main
        Try
            Dim myDESProvider As DESCryptoServiceProvider = New DESCryptoServiceProvider()

            myDESProvider.Key = ASCIIEncoding.ASCII.GetBytes("12345678")
            myDESProvider.IV = ASCIIEncoding.ASCII.GetBytes("12345678")

            Dim DecryptedFile As FileStream = New FileStream("testDes.txt", FileMode.Open, FileAccess.Read)
            Dim myICryptoTransform As ICryptoTransform = myDESProvider.CreateDecryptor(myDESProvider.Key, myDESProvider.IV)
            Dim myCryptoStream As CryptoStream = New CryptoStream(DecryptedFile, myICryptoTransform, CryptoStreamMode.Read)

            Dim myDecStreamReader As New StreamReader(myCryptoStream)
            Dim myDecStreamWriter As New StreamWriter("test.txt")

            myDecStreamWriter.Write(myDecStreamReader.ReadToEnd())

            myCryptoStream.Close()
            myDecStreamReader.Close()
            myDecStreamWriter.Close()
        Catch ex As Exception

            Console.WriteLine(ex.ToString())
        End Try
    End Sub
End Class

   
    
  








Related examples in the same category

1.DESCryptoServiceProvider.CreateEncryptor
2.DESCryptoServiceProvider.CreateEncryptor().TransformFinalBlock