Petite application destinée principalement aux Terminales S spécialité Maths (avec toutefois prolongement vers l'algèbre du supérieur) ; explications sur le cryptage et sur la façon de déterminer la fonction de décryptage ; aide initialement verrouillée.
Source / Exemple :
Public Class Form1
Dim A As Integer
Dim B As Integer
Dim C As Integer
Dim D As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged
TextBox5.Text = ""
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
TextBox4.Text = TextBox2.Text
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim I As Long
Dim Car As Char
Dim F As Integer
TextBox2.Text = ""
For I = 1 To Len(TextBox1.Text)
Car = Mid(TextBox1.Text, I, 1)
F = Asc(Car)
If F >= 97 And F <= 122 Then
F = (A * (F - 97) + B) Mod 26 + 97
ElseIf (F >= 65 And F <= 90) Then
F = (A * (F - 65) + B) Mod 26 + 65
End If
TextBox2.Text = TextBox2.Text + Chr(F)
Next I
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
A = ComboBox1.SelectedItem
TextBox2.Text = ""
End Sub
Private Sub Label9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label9.Click
End Sub
Private Sub ComboBox3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox3.SelectedIndexChanged
B = ComboBox3.SelectedItem
TextBox2.Text = ""
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
TextBox2.Text = ""
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim I As Long
Dim Car As Char
Dim F As Integer
TextBox5.Text = ""
For I = 1 To Len(TextBox4.Text)
Car = Mid(TextBox4.Text, I, 1)
F = Asc(Car)
If F >= 97 And F <= 122 Then
F = (C * (F - 97) + D) Mod 26 + 97
ElseIf (F >= 65 And F <= 90) Then
F = (C * (F - 65) + D) Mod 26 + 65
End If
TextBox5.Text = TextBox5.Text + Chr(F)
Next I
End Sub
Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
C = ComboBox2.SelectedItem
TextBox5.Text = ""
End Sub
Private Sub ComboBox4_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox4.SelectedIndexChanged
D = ComboBox4.SelectedItem
TextBox5.Text = ""
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
TextBox4.Text = TextBox2.Text
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim S As Integer
S = A ^ 11 Mod 26
ComboBox2.Text = S
End Sub
Private Sub CheckBox1_CheckedChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True Then
Button4.Visible = True
Button5.Visible = True
Button10.Enabled = True
Button11.Enabled = True
Else
Button4.Visible = False
Button5.Visible = False
Button10.Enabled = False
Button11.Enabled = False
End If
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
TextBox4.Text = "abcdefghijklmnopqrstuvwxyz"
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim S As Integer
S = A ^ 11 Mod 26
ComboBox4.Text = ((26 - S) * B) Mod 26
End Sub
Private Sub ToolTip1_Popup(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PopupEventArgs)
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
If Not My.Computer.FileSystem.FileExists("Doc1.pdf") Then
Using monstream As New IO.MemoryStream(My.Resources.Doc1)
Using monfichier As New IO.FileStream("Doc1.pdf", IO.FileMode.Create)
monstream.WriteTo(monfichier)
End Using
End Using
End If
Process.Start("Doc1.pdf")
End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
If Not My.Computer.FileSystem.FileExists("Doc2.pdf") Then
Using monstream As New IO.MemoryStream(My.Resources.Doc2)
Using monfichier As New IO.FileStream("Doc2.pdf", IO.FileMode.Create)
monstream.WriteTo(monfichier)
End Using
End Using
End If
Process.Start("Doc2.pdf")
End Sub
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
If Not My.Computer.FileSystem.FileExists("Doc3.pdf") Then
Using monstream As New IO.MemoryStream(My.Resources.Doc3)
Using monfichier As New IO.FileStream("Doc3.pdf", IO.FileMode.Create)
monstream.WriteTo(monfichier)
End Using
End Using
End If
Process.Start("Doc3.pdf")
End Sub
Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
If Not My.Computer.FileSystem.FileExists("Doc4.pdf") Then
Using monstream As New IO.MemoryStream(My.Resources.Doc4)
Using monfichier As New IO.FileStream("Doc4.pdf", IO.FileMode.Create)
monstream.WriteTo(monfichier)
End Using
End Using
End If
Process.Start("Doc4.pdf")
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
If Not My.Computer.FileSystem.FileExists("Doc5.pdf") Then
Using monstream As New IO.MemoryStream(My.Resources.Doc5)
Using monfichier As New IO.FileStream("Doc5.pdf", IO.FileMode.Create)
monstream.WriteTo(monfichier)
End Using
End Using
End If
Process.Start("Doc5.pdf")
End Sub
End Class
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.