Accueil > > > CRYPT / DECRYPT / KEYGEN : UN MODULE CLAIR ET EXTRENEMENT UTILE !
CRYPT / DECRYPT / KEYGEN : UN MODULE CLAIR ET EXTRENEMENT UTILE !
Information sur la source
Description
Voici ENFIN un module ULTRA clair qui montre comment crypter à partir du Clef, décrypter à partir d'une Clef et créer une Clef Randomizée. Le module sert pour : - APPRENDRE - OPERATIONNEL SUR N'IMPORTE QUEL PROGRAMME D'ailleur je vais l'utiliser tout de suite lol ;-)
Source
- 'Tout petit : 3 subs : Aucune gestion des Erreurs mais c'est prévu pour ne pas avoir les Erreurs stupides, cad celles qui sont dues à une réécriture sur un fichier (l'effacement du fichier est automatique si il existe)
-
- 'C'est le module, si vous ne voulez pas apprendre mais vous en servir, décompacter le ZIP avec votre programme et ajouter le module à votre programme.
- 'Vous pourrez dés lors utiliser les instructions :
- '-CRYPT pour crypter
- '-DECRYPT pour décrypter
- '-KEYGEN pour générer une clef randomizer
-
- Sub Crypt(Clef As String, Source As String, Destination As String)
- Dim a As Integer
- Dim b As Double
- Dim c As String * 1
- Dim K(0 To 255) As Integer
- Open Clef For Random As #1 Len = 1
- For a = 1 To 256
- Get #1, a, c
- K(a - 1) = Asc(c)
- Next a
- Close
- If Len(Dir(Destination, 14)) > 0 Then Kill Destination
- Open Source For Random As #1 Len = 1
- Open Destination For Random As #2 Len = 1
- For b = 1 To LOF(1)
- Get #1, b, c
- c = Chr(K(Asc(c)))
- Put #2, b, c
- Next b
- Close
- End Sub
-
- Sub Decrypt(Clef As String, Source As String, Destination As String)
- Dim a As Integer
- Dim b As Double
- Dim c As String * 1
- Dim K(0 To 255) As Integer
- Open Clef For Random As #1 Len = 1
- For a = 1 To 256
- Get #1, a, c
- K(Asc(c)) = a - 1
- Next a
- Close
- If Len(Dir(Destination, 14)) > 0 Then Kill Destination
- Open Source For Random As #1 Len = 1
- Open Destination For Random As #2 Len = 1
- For b = 1 To LOF(1)
- Get #1, b, c
- c = Chr(K(Asc(c)))
- Put #2, b, c
- Next b
- Close
- End Sub
-
- Sub KeyGen(Destination As String)
- Dim a As Integer
- Dim b As Integer
- Dim c As String * 1
- Dim K(0 To 255) As Integer
- For a = 0 To 255
- K(a) = a
- Next a
- Randomize Timer
- If Len(Dir(Destination, 14)) > 0 Then Kill Destination
- Open Destination For Random As #1 Len = 1
- For a = 1 To 256
- Do
- b = Int(Rnd * 256)
- Loop While K(b) < 0
- c = Chr$(K(b))
- Put #1, a, c
- K(b) = -1
- Next a
- Close
- End Sub
'Tout petit : 3 subs : Aucune gestion des Erreurs mais c'est prévu pour ne pas avoir les Erreurs stupides, cad celles qui sont dues à une réécriture sur un fichier (l'effacement du fichier est automatique si il existe)
'C'est le module, si vous ne voulez pas apprendre mais vous en servir, décompacter le ZIP avec votre programme et ajouter le module à votre programme.
'Vous pourrez dés lors utiliser les instructions :
'-CRYPT pour crypter
'-DECRYPT pour décrypter
'-KEYGEN pour générer une clef randomizer
Sub Crypt(Clef As String, Source As String, Destination As String)
Dim a As Integer
Dim b As Double
Dim c As String * 1
Dim K(0 To 255) As Integer
Open Clef For Random As #1 Len = 1
For a = 1 To 256
Get #1, a, c
K(a - 1) = Asc(c)
Next a
Close
If Len(Dir(Destination, 14)) > 0 Then Kill Destination
Open Source For Random As #1 Len = 1
Open Destination For Random As #2 Len = 1
For b = 1 To LOF(1)
Get #1, b, c
c = Chr(K(Asc(c)))
Put #2, b, c
Next b
Close
End Sub
Sub Decrypt(Clef As String, Source As String, Destination As String)
Dim a As Integer
Dim b As Double
Dim c As String * 1
Dim K(0 To 255) As Integer
Open Clef For Random As #1 Len = 1
For a = 1 To 256
Get #1, a, c
K(Asc(c)) = a - 1
Next a
Close
If Len(Dir(Destination, 14)) > 0 Then Kill Destination
Open Source For Random As #1 Len = 1
Open Destination For Random As #2 Len = 1
For b = 1 To LOF(1)
Get #1, b, c
c = Chr(K(Asc(c)))
Put #2, b, c
Next b
Close
End Sub
Sub KeyGen(Destination As String)
Dim a As Integer
Dim b As Integer
Dim c As String * 1
Dim K(0 To 255) As Integer
For a = 0 To 255
K(a) = a
Next a
Randomize Timer
If Len(Dir(Destination, 14)) > 0 Then Kill Destination
Open Destination For Random As #1 Len = 1
For a = 1 To 256
Do
b = Int(Rnd * 256)
Loop While K(b) < 0
c = Chr$(K(b))
Put #1, a, c
K(b) = -1
Next a
Close
End Sub
Conclusion
Ce type de cryptage est extrenement utile pour certains fichiers et faiblement sécurisé pour d'autre type... cherchez et vous comprendrez pourquoi :p
Aller, comme il y a des manipulations d'instructions dans le but d'avoir une autre réponse... je vais mettre niveau 2... Juste de la maîtrise logique.
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
TECHDAYS PARIS 2012 : WINDOWS SERVER "8" QUOI DE 9 !TECHDAYS PARIS 2012 : WINDOWS SERVER "8" QUOI DE 9 ! par ROMELARD Fabrice
Speakers: Fabrice Meillon et Stanislas Quastana Cette session est basée entièrement sur celle donnée lors de la BUILD cet hiver. Il n'y a pas d'ajout d'information en rapport avec cet évènement passé. Windows 8 Server sera intégralem...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice [HTML5] AUTOUR DU W3C : NOUVEAUX STANDARDS ET WEB MOBILE (LILLE)[HTML5] AUTOUR DU W3C : NOUVEAUX STANDARDS ET WEB MOBILE (LILLE) par Gio
Je m'y prends un peu tard je sais, mais bon je suis développeur web et donc hyper fainéant ! Toujours dans le cadre des technologies émergentes, ici HTML5, parce qu'on aime HTML5 chez Wyg , nous seront présent, le vieux ( Aurélien V.) et moi, pour pr...
Cliquez pour lire la suite de l'article par Gio [WP7] DYNAMICALLY CHANGE STARTUP PAGE[WP7] DYNAMICALLY CHANGE STARTUP PAGE par KooKiz
Let's say that you want to allow the user to customize the startup page of your application. You can easily change the startup page by editing the 'NavigationPage' attribute in the manifest file. But the manifest cannot be modified once the applicatio...
Cliquez pour lire la suite de l'article par KooKiz SESSION SILVERLIGHT 5 3D : SLIDES ET DEMOSSESSION SILVERLIGHT 5 3D : SLIDES ET DEMOS par Groc
Durant les techdays, j'ai eu le plaisir d'animer une session sur Silverlight 5 et la 3D avec Simon Ferquel. Comme promis, voici nos slides et mes démos (celles avec le viper BSG) ici et là. Pour mémoire, les démos utilisent toutes le viper BSG...
Cliquez pour lire la suite de l'article par Groc
Logiciels
DocTranslate (V3.1.0.0)DOCTRANSLATE (V3.1.0.0)DocTranslate est un traducteur de document Microsoft Word, PowerPoint et Excel. Il permet d'autom... Cliquez pour télécharger DocTranslate Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System
|