Bonjour tout le monde,

Je suis débutant en VB.net, et je souhaite mettre en place un script qui va décrypter un fichier texte.

Le cryptage de ce fichier a été fait en AES symétrique, et voici le script de décryptage:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
Ma question semble un peu bête, comment spécifier le fichier d'entrée (document crypté) et le fichier de sortie (document décrypté) ?

PS: J'ai essayé de modifier les valeurs "inputFilePath" et "outputFilePath" par le chemin du fichier, mais cela n'aboutit pas au résultat.

Merci pour votre aide,