1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
Imports System.IO
Imports System.Security.Cryptography
Public Class Form1
Private Shared Function Assign(Of T)(ByRef source As T, ByVal value As T) As T
source = value
Return value
End Function
Private Sub Decrypt(inputFilePath As String, outputfilePath As String)
Dim EncryptionKey As String = "MAKV2SPBNI99212"
Using encryptor As Aes = Aes.Create()
Dim pdb As New Rfc2898DeriveBytes(EncryptionKey, New Byte() {&H49, &H76, &H61, &H6E, &H20, &H4D,
&H65, &H64, &H76, &H65, &H64, &H65,
&H76})
encryptor.Key = pdb.GetBytes(32)
encryptor.IV = pdb.GetBytes(16)
Using fs As New FileStream(inputFilePath, FileMode.Open)
Using cs As New CryptoStream(fs, encryptor.CreateDecryptor(), CryptoStreamMode.Read)
Using fsOutput As New FileStream(outputfilePath, FileMode.Create)
Dim data As Integer
While (Assign(data, cs.ReadByte())) <> -1
fsOutput.WriteByte(CByte(data))
End While
End Using
End Using
End Using
End Using
End Sub
End Class |
Partager