Files
Lecteur-media/lecteur/lecteur média/crypte lecteur média.vb
T
2026-06-18 14:15:48 +02:00

57 lines
2.4 KiB
VB.net

Imports System.ComponentModel
Imports System.Security.Cryptography
Imports System.Text
Public Class crypte_lecteur_média
Private Sub crypte_lecteur_média_Load(sender As Object, e As EventArgs) Handles MyBase.Load
BackColor = Form1.BackColor
ForeColor = Form1.ForeColor
TextBox1.BackColor = BackColor
TextBox2.BackColor = BackColor
TextBox3.BackColor = BackColor
TextBox4.BackColor = BackColor
Button1.BackColor = BackColor
Button2.BackColor = BackColor
TextBox1.ForeColor = ForeColor
TextBox2.ForeColor = ForeColor
TextBox3.ForeColor = ForeColor
TextBox4.ForeColor = ForeColor
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then
MsgBox("merci d'entrez le cryptage", MsgBoxStyle.Exclamation)
Else
Dim Resultatbytes() As Byte = Convert.FromBase64String(TextBox1.Text)
Dim keyBytes() As Byte = Encoding.UTF8.GetBytes("Jj@msms7")
Dim Crypto As New DESCryptoServiceProvider()
Crypto.Key = keyBytes
Crypto.IV = keyBytes
Dim Icrypto As ICryptoTransform = Crypto.CreateDecryptor()
Dim donné() As Byte = Icrypto.TransformFinalBlock(Resultatbytes, 0, Resultatbytes.Length)
TextBox2.Text = Encoding.UTF8.GetString(donné)
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If TextBox3.Text = "" Then
MsgBox("merci d'entrez le texte a cryptez", MsgBoxStyle.Exclamation)
Else
Dim texteEnBytes() As Byte = Encoding.UTF8.GetBytes(TextBox3.Text)
Dim keyBytes() As Byte = Encoding.UTF8.GetBytes("Jj@msms7")
Dim Crypto As New DESCryptoServiceProvider()
Crypto.Key = keyBytes
Crypto.IV = keyBytes
Dim Icrypto As ICryptoTransform = Crypto.CreateEncryptor
Dim Resultatbytes() As Byte = Icrypto.TransformFinalBlock(texteEnBytes, 0, texteEnBytes.Length)
Dim passecrypt = Convert.ToBase64String(Resultatbytes)
TextBox4.Text = passecrypt
End If
End Sub
Private Sub crypte_lecteur_média_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
End Sub
End Class