begin process at 2012 05 27 15:19:07
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Maths

 > CRYPTOGRAPHIE AFFINE

CRYPTOGRAPHIE AFFINE


 Information sur la source

Note :
Aucune note
Catégorie :Maths Source .NET ( DotNet ) Classé sous :maths, cryptographie, terminale, algèbre, groupes Niveau :Débutant Date de création :23/12/2011 Date de mise à jour :24/12/2011 14:41:34 Vu / téléchargé :1 780 / 110

Auteur : Tigrou66

Ecrire un message privé
Commentaire sur cette source (9)
Ajouter un commentaire et/ou une note

 Description

Cliquez pour voir la capture en taille normale
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

  • 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
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


 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 Historique

23 décembre 2011 20:15:51 :
Le .exe ne figure pas dans le zip.
23 décembre 2011 21:24:50 :
Ajout des fichiers source.
24 décembre 2011 11:20:26 :
Suppression des sub sans code Zip de tout le dossier du projet hors bin et release.
24 décembre 2011 14:41:35 :
Niveau débutant !

 Sources de la même categorie

Source avec Zip Source .NET (Dotnet) PERMUTATIONS DE CARACTÈRES par alpha5
Source avec Zip Source avec une capture PARTICIPATION À L'APPRENTISSAGE DE LECTURE DE L'HEURE (PENDU... par oulipan
Source avec Zip Source avec une capture TECHNIQUE TRADITIONNELLE DE LA DIVISION par oulipan
Source avec Zip Source avec une capture ENTRAÎNEMENT POUR EFFECTUER DES MULTIPLICATIONS EN COLONNES ... par oulipan
Source avec Zip Source avec une capture CONVERTISSEUR HEXAVIGÉSIMAL par shaeks

 Sources en rapport avec celle ci

Source avec Zip Source avec une capture TECHNIQUE TRADITIONNELLE DE LA DIVISION par oulipan
Source avec Zip Source avec une capture SECURITEMESSAGE,CRYPTER,CRYPTOGRAPHIE par okosa
Source avec Zip Source avec une capture ASSOCIER PAR UN TRAIT LES ÉLÉMENTS CORRESPONDANTS DE DEUX LI... par oulipan
Source avec Zip Source avec une capture CRYPTER AVEC LE CHIFFRE DES NIHILISTES RUSSES par tresorsdevie
Source avec Zip Source .NET (Dotnet) CUSTOMTOOLS, DIVERS OUTILS MATHÉMATIQUES UTILES... par moutonjr

Commentaires et avis

Commentaire de NHenry le 23/12/2011 18:54:17 administrateur CS

Bonsoir,

Afin d'améliorer ta source :
- Tu fais appel à des ressources : My.Resources.Doc1 : Mais il y a pas de zip ...
- Essayes de faire un module pour (dé)crypter une chaine, cela facilitera la réutilisation de ton code.
- Quelles sont les limites de ton cryptage (bien que ça ressemble plus à un hash).

Commentaire de Tigrou66 le 23/12/2011 20:41:29

Salut ,

effectivement il n 'y a rien dans le zip excepté ce que le serveur ajoute ; j'avais mis le .exe; faut-il ne mettre que la form ?



Commentaire de NHenry le 23/12/2011 20:49:14 administrateur CS

Les .EXE sont supprimés des zips.
De plus, c'est un site de partage, donc, on met les sources.

Commentaire de Tigrou66 le 23/12/2011 21:01:39

Quels fichiers dois-je poster ? Il y en a un tas dans le dossier de l'application.

Commentaire de Adn56 le 23/12/2011 21:20:02

quote => "Quels fichiers dois-je poster ? Il y en a un tas dans le dossier de l'application."

euh pourquoi un niveau initié ?

tu nettoies ta source des repertoires bin et release, tu la zip et tu la post, c'est tout bête....

bonne fêtes et bonne prog ;)

Commentaire de Tigrou66 le 23/12/2011 21:31:24

Initié à quoi exactement c'est là la question...

Je ne voulais mettre que le nécessaire ; j'ai copié trois fichiers et les ressources et pas de problème : on peut reconstituer le tout en créant un nouveau projet ; à condition bien sûr de ré-enregistrer les ressources.

Commentaire de Adn56 le 23/12/2011 23:22:26

bha initié en codage pardi ! ton code offre un algo matheu, ok, mais what else ?
je regarde ta source demain, bon noël et bonne prog sieur.

Commentaire de Tigrou66 le 24/12/2011 08:27:45

Salut ,

en fait il n'y a pas d'algo proprement dit puisque la fonction de décryptage s'obtient directement :
C = A ^ 11 Mod 26  et D = ((26 - C) * B) Mod 26    (plus simplement (-C * B) Mod 26 mais ça ne retourne pas un résidu positif).

Vu l'objectif de l'appli je suis pas tout à fait au bon endroit ?





Commentaire de Adn56 le 24/12/2011 09:58:55

j'suis pas balaise en math donc je ne pige pas tout, mais en revanche je t'invite vivement à commencer ton codage par :
Option Strict On
Option Explicit On

Ensuite de virer les sub qui ne servent à rien (form_load notamment).
et pour finir de poster en zip le projet complet avec les rep bin et release vide.
kenavo et vivement 2012 ^^

 Ajouter un commentaire


Discussions en rapport avec ce code source dans le forum

[Cryptographie] RSA [ par Rurouni ] Bonjour,Je suis en train d essayer de faire un RSA en visual basic selon la demandede mon maitre de stage.J en suis au point de calculer la clef prive Comment créer dynamiquesment des groupes de controls ? [ par xavier ] Salut, j'arrive à créer dynamiquement des controls dans une fenetre, ne sachant pas à l'avance quels sont les types et le nombre de ces controls. J'ut comment créer dynamiquement des groupes de controls ? [ par xavier ] Qqun sait comment je peux faire pour créer dynamiquement des groupes de controls ?Exemple : créer un nombre choisi de frames avec un nombre choisi d'o Récupération des groupes utilisateurs sous ACCESS [ par Nitocris ] Lorsqu'une base est sécurisé avec l'assistant d'ACCESS.Comment peut-on récupérer sous la forme d'une String le ou les groupe(s) d'utilisateur auquel i Macro Word + visual basic [ par voily2001 ] Salut ,voila je vous expose mon problème.J'ai un fichier texte de compremant des groupes de lignes séparées par des sauts de page.Ensuite j'ai un tab pb avec mscomm [ par zagalo ] salutj'ai fait un terminale telephonique avec le mscomm de visual basic,le programme fontionne correctement (il compose un numéro j'ecoute la voix de VBS, WMI & groupes locaux [ par rodrigos ] Salut!Je suis en train de me mettre au vbscript et j'aimerai savoir comment on peut obtenir l'ensemble des utilisateurs d'un groupe local: par exemple Shape Group [ par starsky ] Bonjour à tous,J'ai une feuille dans laquelle se trouve 3 groupes de plusieurs checkBox chacune: mon problème est de connaître les valeurs de ces chec


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,640 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales