begin process at 2012 02 16 15:19:20
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Sécurité

 > SUBSTITUTION POLYALPHABÉTIQUE (VIGENERE)

SUBSTITUTION POLYALPHABÉTIQUE (VIGENERE)


 Information sur la source

Note :
6,5 / 10 - par 2 personnes
6,50 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Sécurité Niveau :Débutant Date de création :09/01/2002 Date de mise à jour :09/01/2002 13:12:22 Vu :4 698

Auteur : Majen

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

 Description

  Vigenère a inventé son code au XVIème siècle
selon un procédé voisin de celui de César.
S'agissant d'un code à polyalphabétique,
l'algorithme consiste à substituer à chaque
lettre du message une lettre de l'alphabet. La
lettre de substitution étant calculée
à partir d'une clef et dépend de la position de
la lettre codée dans le message.
Par exemple, On veut coder la phrase "II FAIT
BEAU" avec la clé "ZORRO"

I L F A I T B E A U
Z O R R O Z O R R O
I A X S X T Q W S J

Ce qui, transcrit sous formes de chiffres en
affectant à chaque lettre sa place dans
l'alphabet en partant de A, donne:

   9 12  6  1  9 20  2  5  1 21
+ 26 15 18 18 15 26 15 18 18 15
   9  1 24 19 24 20 17 23 19 10

  Comme l'alphabet latin est constitué de 26
lettres, il faut effectuer une addition modulo
26, afin de garder des nombres compris entre 1 et
26. Pour le décryptage, il suffit de procéder à
l'opération inverse, c'est à dire une simple
soustraction.
L'avantage de cet algorithme par rapport à celui
de César est qu'il est un peu plus compliqué à
déchiffrer du fait de l'utilisation d'une clef
secrète et qu'à chaque caractère
correspond plusieurs autres caractères. Mais
aussi, plus la clé est longue, plus le message
est difficile à décrypter.

Source

  • Dim x, xx, xxx, xxxx
  • Dim a, b, y, yy
  • Dim Clef
  • Private Sub Command1_Click()
  • Text2 = ""
  • Clef = Text3
  • Do While Len(Text3) < Len(Text1)
  • Text3 = Text3 & Clef
  • Loop
  • For i = 1 To Len(Text1)
  • a = Mid$(Text1, i, 1)
  • b = Mid$(Text3, i)
  • If a = " " Then Text3 = Mid$(Text3, 1, i - 1) & " " & b
  • Next i
  • Text3 = Mid$(Text3, 1, Len(Text1))
  • Crypter
  • End Sub
  • Private Sub Crypter()
  • Text2 = ""
  • For i = 1 To Len(Text1)
  • x = Mid$(Text1, i, 1)
  • If x = "a" Or x = "A" Or x = "b" Or x = "B" Or x = "c" Or x = "C" Or x = "d" Or x = "D" Or x = "e" Or x = "E" Or x = "f" Or x = "F" Or x = "g" Or x = "G" Or x = "h" Or x = "H" Or x = "i" Or x = "I" Or x = "j" Or x = "J" Or x = "k" Or x = "K" Or x = "l" Or x = "L" Or x = "m" Or x = "M" Or x = "n" Or x = "N" Or x = "o" Or x = "O" Or x = "p" Or x = "P" Or x = "q" Or x = "Q" Or x = "r" Or x = "R" Or x = "s" Or x = "S" Or x = "t" Or x = "T" Or x = "u" Or x = "U" Or x = "v" Or x = "V" Or x = "w" Or x = "W" Or x = "x" Or x = "X" Or x = "y" Or x = "Y" Or x = "z" Or x = "Z" Then
  • ' Valeur de la lettre du msg non crypté
  • If x = "a" Or x = "A" Then xx = 1
  • If x = "b" Or x = "B" Then xx = 2
  • If x = "c" Or x = "C" Then xx = 3
  • If x = "d" Or x = "D" Then xx = 4
  • If x = "e" Or x = "E" Then xx = 5
  • If x = "f" Or x = "F" Then xx = 6
  • If x = "g" Or x = "G" Then xx = 7
  • If x = "h" Or x = "H" Then xx = 8
  • If x = "i" Or x = "I" Then xx = 9
  • If x = "j" Or x = "J" Then xx = 10
  • If x = "k" Or x = "K" Then xx = 11
  • If x = "l" Or x = "L" Then xx = 12
  • If x = "m" Or x = "M" Then xx = 13
  • If x = "n" Or x = "N" Then xx = 14
  • If x = "o" Or x = "O" Then xx = 15
  • If x = "p" Or x = "P" Then xx = 16
  • If x = "q" Or x = "Q" Then xx = 17
  • If x = "r" Or x = "R" Then xx = 18
  • If x = "s" Or x = "S" Then xx = 19
  • If x = "t" Or x = "T" Then xx = 20
  • If x = "u" Or x = "U" Then xx = 21
  • If x = "v" Or x = "V" Then xx = 22
  • If x = "w" Or x = "W" Then xx = 23
  • If x = "x" Or x = "X" Then xx = 24
  • If x = "y" Or x = "Y" Then xx = 25
  • If x = "z" Or x = "Z" Then xx = 26
  • ' Valeur de la lettre de la clef
  • xxx = Mid$(Text3, i, 1)
  • If xxx = "a" Or xxx = "A" Then xxxx = 1
  • If xxx = "b" Or xxx = "B" Then xxxx = 2
  • If xxx = "c" Or xxx = "C" Then xxxx = 3
  • If xxx = "d" Or xxx = "D" Then xxxx = 4
  • If xxx = "e" Or xxx = "E" Then xxxx = 5
  • If xxx = "f" Or xxx = "F" Then xxxx = 6
  • If xxx = "g" Or xxx = "G" Then xxxx = 7
  • If xxx = "h" Or xxx = "H" Then xxxx = 8
  • If xxx = "i" Or xxx = "I" Then xxxx = 9
  • If xxx = "j" Or xxx = "J" Then xxxx = 10
  • If xxx = "k" Or xxx = "K" Then xxxx = 11
  • If xxx = "l" Or xxx = "L" Then xxxx = 12
  • If xxx = "m" Or xxx = "M" Then xxxx = 13
  • If xxx = "n" Or xxx = "N" Then xxxx = 14
  • If xxx = "o" Or xxx = "O" Then xxxx = 15
  • If xxx = "p" Or xxx = "P" Then xxxx = 16
  • If xxx = "q" Or xxx = "Q" Then xxxx = 17
  • If xxx = "r" Or xxx = "R" Then xxxx = 18
  • If xxx = "s" Or xxx = "S" Then xxxx = 19
  • If xxx = "t" Or xxx = "T" Then xxxx = 20
  • If xxx = "u" Or xxx = "U" Then xxxx = 21
  • If xxx = "v" Or xxx = "V" Then xxxx = 22
  • If xxx = "w" Or xxx = "W" Then xxxx = 23
  • If xxx = "x" Or xxx = "x" Then xxxx = 24
  • If xxx = "y" Or xxx = "Y" Then xxxx = 25
  • If xxx = "z" Or xxx = "Z" Then xxxx = 26
  • ' Addition des 2 valeurs
  • y = xx + xxxx
  • ' On réduit y pour avoir un nbr egal ou supérieur à 26
  • Do While y >= 26
  • y = y - 26
  • Loop
  • ' On remplace y par la lettre correspondante
  • If y = 1 Then yy = "a"
  • If y = 2 Then yy = "b"
  • If y = 3 Then yy = "c"
  • If y = 4 Then yy = "d"
  • If y = 5 Then yy = "e"
  • If y = 6 Then yy = "f"
  • If y = 7 Then yy = "g"
  • If y = 8 Then yy = "h"
  • If y = 9 Then yy = "i"
  • If y = 10 Then yy = "j"
  • If y = 11 Then yy = "k"
  • If y = 12 Then yy = "l"
  • If y = 13 Then yy = "m"
  • If y = 14 Then yy = "n"
  • If y = 15 Then yy = "o"
  • If y = 16 Then yy = "p"
  • If y = 17 Then yy = "q"
  • If y = 18 Then yy = "r"
  • If y = 19 Then yy = "s"
  • If y = 20 Then yy = "t"
  • If y = 21 Then yy = "u"
  • If y = 22 Then yy = "v"
  • If y = 23 Then yy = "w"
  • If y = 24 Then yy = "x"
  • If y = 25 Then yy = "y"
  • If y = 26 Then yy = "z"
  • ' On affiche le résultat
  • Text2 = Text2 & yy
  • Else
  • Text2 = Text2 & " "
  • End If
  • Next i
  • Text3 = Clef
  • End Sub
Dim x, xx, xxx, xxxx
Dim a, b, y, yy
Dim Clef

Private Sub Command1_Click()
Text2 = ""
Clef = Text3
  Do While Len(Text3) < Len(Text1)
    Text3 = Text3 & Clef
  Loop
  For i = 1 To Len(Text1)
      a = Mid$(Text1, i, 1)
      b = Mid$(Text3, i)
    If a = " " Then Text3 = Mid$(Text3, 1, i - 1) & " " & b
  Next i
Text3 = Mid$(Text3, 1, Len(Text1))
Crypter
End Sub

Private Sub Crypter()
Text2 = ""
For i = 1 To Len(Text1)
x = Mid$(Text1, i, 1)
 If x = "a" Or x = "A" Or x = "b" Or x = "B" Or x = "c" Or x = "C" Or x = "d" Or x = "D" Or x = "e" Or x = "E" Or x = "f" Or x = "F" Or x = "g" Or x = "G" Or x = "h" Or x = "H" Or x = "i" Or x = "I" Or x = "j" Or x = "J" Or x = "k" Or x = "K" Or x = "l" Or x = "L" Or x = "m" Or x = "M" Or x = "n" Or x = "N" Or x = "o" Or x = "O" Or x = "p" Or x = "P" Or x = "q" Or x = "Q" Or x = "r" Or x = "R" Or x = "s" Or x = "S" Or x = "t" Or x = "T" Or x = "u" Or x = "U" Or x = "v" Or x = "V" Or x = "w" Or x = "W" Or x = "x" Or x = "X" Or x = "y" Or x = "Y" Or x = "z" Or x = "Z" Then
' Valeur de la lettre du msg non crypté
  If x = "a" Or x = "A" Then xx = 1
  If x = "b" Or x = "B" Then xx = 2
  If x = "c" Or x = "C" Then xx = 3
  If x = "d" Or x = "D" Then xx = 4
  If x = "e" Or x = "E" Then xx = 5
  If x = "f" Or x = "F" Then xx = 6
  If x = "g" Or x = "G" Then xx = 7
  If x = "h" Or x = "H" Then xx = 8
  If x = "i" Or x = "I" Then xx = 9
  If x = "j" Or x = "J" Then xx = 10
  If x = "k" Or x = "K" Then xx = 11
  If x = "l" Or x = "L" Then xx = 12
  If x = "m" Or x = "M" Then xx = 13
  If x = "n" Or x = "N" Then xx = 14
  If x = "o" Or x = "O" Then xx = 15
  If x = "p" Or x = "P" Then xx = 16
  If x = "q" Or x = "Q" Then xx = 17
  If x = "r" Or x = "R" Then xx = 18
  If x = "s" Or x = "S" Then xx = 19
  If x = "t" Or x = "T" Then xx = 20
  If x = "u" Or x = "U" Then xx = 21
  If x = "v" Or x = "V" Then xx = 22
  If x = "w" Or x = "W" Then xx = 23
  If x = "x" Or x = "X" Then xx = 24
  If x = "y" Or x = "Y" Then xx = 25
  If x = "z" Or x = "Z" Then xx = 26
' Valeur de la lettre de la clef
 xxx = Mid$(Text3, i, 1)
  If xxx = "a" Or xxx = "A" Then xxxx = 1
  If xxx = "b" Or xxx = "B" Then xxxx = 2
  If xxx = "c" Or xxx = "C" Then xxxx = 3
  If xxx = "d" Or xxx = "D" Then xxxx = 4
  If xxx = "e" Or xxx = "E" Then xxxx = 5
  If xxx = "f" Or xxx = "F" Then xxxx = 6
  If xxx = "g" Or xxx = "G" Then xxxx = 7
  If xxx = "h" Or xxx = "H" Then xxxx = 8
  If xxx = "i" Or xxx = "I" Then xxxx = 9
  If xxx = "j" Or xxx = "J" Then xxxx = 10
  If xxx = "k" Or xxx = "K" Then xxxx = 11
  If xxx = "l" Or xxx = "L" Then xxxx = 12
  If xxx = "m" Or xxx = "M" Then xxxx = 13
  If xxx = "n" Or xxx = "N" Then xxxx = 14
  If xxx = "o" Or xxx = "O" Then xxxx = 15
  If xxx = "p" Or xxx = "P" Then xxxx = 16
  If xxx = "q" Or xxx = "Q" Then xxxx = 17
  If xxx = "r" Or xxx = "R" Then xxxx = 18
  If xxx = "s" Or xxx = "S" Then xxxx = 19
  If xxx = "t" Or xxx = "T" Then xxxx = 20
  If xxx = "u" Or xxx = "U" Then xxxx = 21
  If xxx = "v" Or xxx = "V" Then xxxx = 22
  If xxx = "w" Or xxx = "W" Then xxxx = 23
  If xxx = "x" Or xxx = "x" Then xxxx = 24
  If xxx = "y" Or xxx = "Y" Then xxxx = 25
  If xxx = "z" Or xxx = "Z" Then xxxx = 26
' Addition des 2 valeurs
 y = xx + xxxx
' On réduit y pour avoir un nbr egal ou supérieur à 26
    Do While y >= 26
      y = y - 26
    Loop
' On remplace y par la lettre correspondante
  If y = 1 Then yy = "a"
  If y = 2 Then yy = "b"
  If y = 3 Then yy = "c"
  If y = 4 Then yy = "d"
  If y = 5 Then yy = "e"
  If y = 6 Then yy = "f"
  If y = 7 Then yy = "g"
  If y = 8 Then yy = "h"
  If y = 9 Then yy = "i"
  If y = 10 Then yy = "j"
  If y = 11 Then yy = "k"
  If y = 12 Then yy = "l"
  If y = 13 Then yy = "m"
  If y = 14 Then yy = "n"
  If y = 15 Then yy = "o"
  If y = 16 Then yy = "p"
  If y = 17 Then yy = "q"
  If y = 18 Then yy = "r"
  If y = 19 Then yy = "s"
  If y = 20 Then yy = "t"
  If y = 21 Then yy = "u"
  If y = 22 Then yy = "v"
  If y = 23 Then yy = "w"
  If y = 24 Then yy = "x"
  If y = 25 Then yy = "y"
  If y = 26 Then yy = "z"
' On affiche le résultat
  Text2 = Text2 & yy
 Else
  Text2 = Text2 & " "
 End If
Next i
Text3 = Clef
End Sub
 

 Conclusion

Text1 = msg "normal"
Text2 = msg crypté
Text3 = clef


 Sources du même auteur

Source avec Zip SERIAL RENAMER
Source avec Zip TEST DE LUCIDIDÉ
Source avec Zip MORSE
Source avec Zip INTRODUCTION AU VISUAL BASIC
Source avec Zip Source avec une capture ECOUTEZ 205 RADIOS SUR VOTRE PC SANS PUB

 Sources de la même categorie

Source avec Zip Source avec une capture Source .NET (Dotnet) CHIFFREMENT XOR PLUS ROBUSTE par dheroux
Source avec Zip CRYPTAGE MARANT par alpha5
Source avec Zip ACCÈS PAR MOT DE PASSE À FEUILLE EXCEL par mimiZanzan
Source avec Zip CRYPTER-DÉCRYPTER UN TEXTE - TEXTE CRYPTÉ UNIQUEMENT EN MAJ... par Saintache
Source avec Zip Source avec une capture FOLDER PROTECTION par hackoo

Commentaires et avis

Commentaire de Cyrus le 09/01/2002 13:30:22

J'aime beaucoup ta méthode de cryptage. Mais il y a encore un moyen de l'améliorer : si tu places plus d'une clef pour coder ton message, celui-ci deviendra totalement inviolable.

Commentaire de TTMan le 09/01/2002 13:30:27

Bien, mais quelle est la protection effective?
(réponds à tt123it@yahoo.fr)
TTMan

Commentaire de Cyrus le 09/01/2002 13:41:51

Tu peux simplifier tes tests en faisant ceci :

x=asc(Mid$(Text1, i, 1))
if x&gt;64 and x&lt;91 then xx=x-64
if x&gt;96 and x&lt;123 then xx=x-95

xxx = asc(Mid$(Text3, i, 1))
if xxx&gt;64 and xxx&lt;91 then xxxx=xxx-64
if xxx&gt;96 and xxx&lt;123 then xxxx=xxx-95

puis pour y : yy=chr(64+y)

Commentaire de Majen le 11/01/2002 22:45:27

merci, oui je sais, on pourrait faire plus simple, plus efficase et plus cours, ms c'est juste un exemple :]

Commentaire de djicfr le 07/04/2004 19:41:14

C'est quoi tous ces If !!!!

 Ajouter un commentaire




Nos sponsors


Sondage...

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

Photothèque

 
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 : 1,092 sec (3)

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