Tout sur la programmation
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
Tout sur la programmation

programmation de tous les languages
 
AccueilPortailRechercherDernières imagesS'enregistrerConnexion
Le Deal du moment : -45%
WHIRLPOOL OWFC3C26X – Lave-vaisselle pose libre ...
Voir le deal
339 €

 

 cryptage de données

Aller en bas 
AuteurMessage
Black Templar
Admin
Admin
Black Templar


Nombre de messages : 356
Age : 35
Localisation : Lille (France)
language de prog : Liberty BASIC; HTML; CSS; php; MySQL; C
expérience en prog : Amateur
Date d'inscription : 06/08/2005

cryptage de données Empty
MessageSujet: cryptage de données   cryptage de données EmptyMar 23 Aoû - 10:28

Voila, C'est fini! Smile

Code:
'***************************************************
'* CRYPTAGE v:2.1                                  *
'*                                                *
'* Created by Black Templar Août 2005              *
'*                                                *
'* programme permettant de crypter, décrypter et  *
'* enregistrer des données en format ".txt"        *
'*                                                *
'* OPEN SOURCE                                    *
'***************************************************
nomainwin
dim tx$(5)
WindowHeight = 275
WindowWidth = 230
UpperLeftX = 100
UpperLeftY = 50
menu #1, "&Fichier", "Nouveau", [new], "Ouvrir", [ouvrir], "Enregistrer", [enr], "Quitter", [quit]
radiobutton #1.rc, "Crypter", [crypter], [wait], 10, 10, 50, 20
radiobutton #1.rd, "Décrypter", [décrypter], [wait], 70, 10, 70, 20
statictext #1, "Clé :", 10, 40, 50, 20
statictext #1, "Texte :", 10, 70, 50, 20
statictext #1, "Résultat :", 10, 130, 50, 20
textbox #1.clé, 60, 40, 150, 20
textbox #1.txt, 60,70, 150, 20
button #1.cr, "Crypter", [cr], UL, 10, 100, 100, 20
button #1.dy, "Décrypter", [dy], UL, 110, 100, 100, 20
texteditor #1.txedit, 60, 130, 150, 80
open "crypter v: 2.1" for Window as #1
print #1, "trapclose [quit]"
#1.cr, "!hide"
#1.dy, "!hide"
call NoEdit
wait

[crypter]
#1.dy, "!hide"
#1.cr, "!show"
wait

[décrypter]
#1.cr, "!hide"
#1.dy, "!show"
wait

'code pour décrypter (inverse du cryptage)
[dy]
print #1.clé, "!contents?"
input #1.clé, clé$
print #1.txt, "!contents?"
input #1.txt, ch$
ch$ = trim$(ch$)
ch = len(ch$)
dim lcr(ch)

for z = 1 to ch
    cr$ = mid$(ch$,z,1)
    lcr(z) = asc(cr$)
next

for z = 1 to len(clé$)
    cr$ = mid$(clé$,z,1)
    cléc(z) = asc(cr$)
next

cl = 1
for z = 1 to ch
    lcr(z) = lcr(z) - cléc(cl)
    cl = cl + 1
    if cl > len(clé$) then cl = 1
next

txtdé$ = ""

for z = 1 to ch
    if lcr(z) < 33 then lcr(z) = lcr(z) + 92
    if chr$(lcr(z)) = "|" then
        txtdé$ = txtdé$ + " "
    else
        txtdé$ = txtdé$ + chr$(lcr(z))
    end if
next

txtcr$ = ""
print txtdé$
tx$(1) = txtdé$
goto [result]
wait

'code pour crypter
[cr]

print #1.clé, "!contents?"
input #1.clé, clé$
print #1.txt, "!contents?"
input #1.txt, ch$
ch$ = trim$(ch$)
ch = len(ch$)
dim lcr(ch)

'crypte le txt (utilise l'ASCII)
for z = 1 to ch
    cr$ = mid$(ch$,z,1)
    lcr(z) = asc(cr$)
next

'par le m^ procédé, crypte la clé
for z = 1 to len(clé$)
    cr$ = mid$(clé$,z,1)
    cléc(z) = asc(cr$)
next

'Additionne le cryptage clé avec celui du txt
cl = 1
for z = 1 to ch
    lcr(z) = lcr(z) + cléc(cl)
    cl = cl + 1
    if cl > len(clé$) then cl = 1
next

txtcr$ = ""

'Transforme le cryptage numérique en alphanumérique grâce à l'ASCII
for z = 1 to ch
    'crypte avec les caractères couramment utilisé au clavier
    if lcr(z) > 126 then lcr(z) = lcr(z) - 92
    txtcr$ = txtcr$ + chr$(lcr(z))
next

'affiche la réponse
txtdé$ = ""
print txtcr$
tx$(1) = txtcr$
goto [result]
wait

[quit]
close #1
end

[wait]
wait

'********** Enregistrement **********
[enr]
nom$ = ""
filedialog "Save as...", "*.txt", nom$
if nom$ = "" then
notice "tapez un nom de fichier !"
wait
end if
if txtcr$ = "" then
notice "Il n'y a rien à enregistrer !"
wait
end if
nom$ = nom$ + ".txt"
open nom$ for output as #enregistrer
print #enregistrer, txtcr$
print #1.txt, ""
print #1.clé, ""
print #1.txedit, "!cls"
close #enregistrer
wait

'********** Ouvrir un fichier **********
[ouvrir]
nom$ = ""
filedialog "Ouvrir :", "*.txt", nom$
if nom$ = "" then
notice "tapez un nom de fichier !"
goto [ouvrir]
end if
if right$(nom$, 4) <> ".txt" then
notice "Vous devez selectionner un fichier texte !"
wait
end if
open nom$ for input as #ouvrir
line input #ouvrir, drc$
print #1.txt, drc$
print #1.clé, ""
print #1.txedit, "!cls"
close #ouvrir
wait

[new]
print #1.clé, ""
print #1.txt, ""
print #1.txedit, "!cls"
txtcr$ = ""
txtdy$ = ""
wait

'********** Affiche le résultat dans Texteditor **********
[result]
if len(tx$(1)) > 105 then
notice "Vous ne pouvez pas dépacer 105 caractère !"
wait
end if
print #1.txedit, "!cls"
a = 1
while len(tx$(1)) > 21
a = a + 1
tx$(a) = left$(tx$(1), 21)
tx$(1) = right$(tx$(1), len(tx$(1)) - 21)
wend
for z = 2 to a
print #1.txedit, tx$(z)
next
print #1.txedit, tx$(1)
wait


'********** Efface le menu "edit" **********
Sub NoEdit
    hMain=hWnd(#1)
    hMainMenu=GetMenu(hMain)
    hMainEdit=GetSubMenu(hMainMenu,1)
    result=RemoveMenu(hMainMenu,hMainEdit)
    Call DrawMenuBar hWnd(#1)
    End Sub

Sub DrawMenuBar hWnd
    CallDLL #user32, "DrawMenuBar",_
    hWnd As long, r As boolean
    End Sub

Function GetSubMenu(hMenuBar,nPos)
    CallDLL #user32, "GetSubMenu",_
    hMenuBar As long, nPos As long,_
    GetSubMenu As long
    End Function

Function GetMenu(hWnd)
    CallDLL #user32, "GetMenu",hWnd As long,_
    GetMenu As long
    End Function

Function RemoveMenu(hMenu,hSubMenu)
    CallDLL #user32, "RemoveMenu", hMenu As long,_
    hSubMenu As long, _MF_BYCOMMAND As long,_
    RemoveMenu As boolean
    End Function

Revenir en haut Aller en bas
http://membres.multimania.fr/templar59
 
cryptage de données
Revenir en haut 
Page 1 sur 1
 Sujets similaires
-
» cryptage et décryptage
» cryptage d'une carte bancaire

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
Tout sur la programmation :: Programmation :: Programmes-
Sauter vers: