Cryptage par direction (c'est du basic pas du vb)

Contenu du snippet

Bon c'est pas génial, c'est pas du VB c'est du liberty BASIC mais j'essaie quand même. Le logiciel est assez simple.
Tu entre un mot de passe, tu entre tes directions, et tu selectionnes tes fichiers, le programme enregistre tout ca et
inverse les syllabes, en enregistrant le fichier sous une extension que seul le programme peut lire

Source / Exemple :


[setup.choix.Window]

    '-----Begin code for #choix

    WindowWidth = 140
    WindowHeight = 135
    UpperLeftX=int((DisplayWidth-WindowWidth)/2)
    UpperLeftY=int((DisplayHeight-WindowHeight)/2)

    '-----Begin GUI objects code

    radiobutton #choix.Protect, "Protéger", [ProtectSet], [ProtectReset],  25,  12,  77,  25
    radiobutton #choix.deproteger, "deproteger", [deprotegerSet], [deprotegerReset],  25,  37,  92,  25
    button #choix.choixvalid,"Valid",[choix.valid], UL,  45,  67,  41,  25

    '-----End GUI objects code

    open "Choose " for window as #choix
    print #choix, "font ms_sans_serif 10"
    print #choix, "trapclose [quit.choix]"

[choix.inputLoop]   'wait here for input event
    wait

[ProtectSet]   'Perform action for the radiobutton named 'Protect'
    Protect = 1
    Deprotect = 0
    wait

[ProtectReset]   'Perform action for the radiobutton named 'Protect'
    Protect = 0
    Deprotect = 0

    wait

[deprotegerSet]   'Perform action for the radiobutton named 'deproteger'
    Protect = 0
    Deprotect = 1
    wait

[deprotegerReset]   'Perform action for the radiobutton named 'deproteger'
    Protect = 0
    Deprotect = 0
    wait

[choix.valid]   'Perform action for the button named 'choixvalid'
    if Protect = 1 then
        name$ = "C:\Windows\" + name$ + ".lrg"
        close #choix
        goto [setup.new.Window]
    end if
    if Deprotect = 1 then
        close #choix
        goto [setup.code.Window]
    end if
    wait

[quit.choix] 'End the program
    close #choix
    end

[setup.new.Window]

    '-----Begin code for #new

    WindowWidth = 430
    WindowHeight = 155
    UpperLeftX=int((DisplayWidth-WindowWidth)/2)
    UpperLeftY=int((DisplayHeight-WindowHeight)/2)

    '-----Begin GUI objects code

    TextboxColor$ = "white"
    textbox #new.entry1, 125,   7,  25,  25
    textbox #new.filetoprotect, 140,  37, 275,  25
    statictext #new.statictext3, "Nombre d'entrée",   5,  12, 101,  20
    statictext #new.statictext4, "Fichier à protéger : ",   5,  42, 120,  20
    button #new.valid.new,"Valider",[valid.new], UL, 265,  97,  41,  25
    statictext #new.statictext9, "Nombre de croisement :", 240,  12, 143,  20
    textbox #new.croisement, 390,   7,  25,  25
    statictext #new.statictext11, "Adresse du Fichier protégé",   0,  72, 170,  20
    textbox #new.AdreFilePro, 175,  67, 240,  25
    statictext #new.statictext14, "Entrez un mot :",   0, 102,  85,  20
    textbox #new.name,  90,  97, 100,  25

    '-----End GUI objects code

    open "Nouveau : " for window as #new
    print #new, "font ms_sans_serif 10"
    print #new, "trapclose [quit.new]"

[new.inputLoop]   'wait here for input event
    wait

[quit.new] 'End the program
    confirm "Are you sure"; yes$
    if yes$ = "no" then wait
    close #new
    end

[valid.new]

    print #new.entry1, "!contents? nbrentry$"
    print #new.filetoprotect, "!contents? trail$"
    print #new.AdreFilePro, "!contents? chemin$"
    print #new.croisement, "!contents? nbrcrois$"
    print #new.name, "!contents? name$"

    if name$ = "" then wait
    if nbrentry$ = "" then wait

    nbrentry1 = val(word$(nbrentry$, 1))

    if nbrentry1 > 3 then
        print #new.entry1, "too big"
        wait
    end if
    if nbrentry1 <= 0 then
        print #new.entry1, "too small"
        wait
    end if
    if trail$ = "" then
        print #new.filetoprotect, "no files specified"
        wait
    end if
    if chemin$ = "" then
        print #new.AdreFilePro, "pas de chemin spécifié"
        wait
    end if

    nbrcrois = val(word$(nbrcrois$,1))

    if nbrcrois <= 0 then
        print #new.croisement, "???"
        wait
    end if
    if nbrcrois > 25 then
        print #new.croisement, "Too big"
        wait
    end if

    num = len(chemin$)
    num = num - 4
    l$ = mid$(chemin$, num, 1)

    if l$ = "." then
        print #new.AdreFilePro, "pas d'extension"
        wait
    end if

    sens$ = left$(trail$,3)

    if sens$ = "C:\" then
        print #new.filetoprotect, "Remove C:\"
        wait
    end if
    dim info$(1, 1)
    files "c:\", trail$, info$(

    if val(info$(0, 0)) <= 0 then
        print #new.filetoprotect, "Don't exist, please remove C:\ or change the repertory"
        wait
     else
        print #new.filetoprotect, "G"
    end if
name$ = "C:\Windows\" + name$
close #new
i = 1

[setup.direction.Window]

    '-----Begin code for #direction

    WindowWidth = 425
    WindowHeight = 185
    UpperLeftX=int((DisplayWidth-WindowWidth)/2)
    UpperLeftY=int((DisplayHeight-WindowHeight)/2)

    '-----Begin GUI objects code

    statictext #direction.statictext1, "Nombre de croisement restant :",   5,  17, 186,  20
    statictext #direction.statictext2, nbrcrois$, 200,  17,  28,  20
    statictext #direction.statictext3, "Dans quel sens voulez vous allez :",   5,  42, 204,  20
    radiobutton #direction.radiobutton4, "Avant", [AvantSet], [AvantReset], 215,  42,  59,  25
    radiobutton #direction.radiobutton5, "Gauche", [GaucheSet], [GaucheReset], 280,  42,  72,  25
    radiobutton #direction.radiobutton6, "Droite", [DroiteSet], [DroiteReset], 355,  42,  61,  25
    statictext #direction.statictext7, "Quel lettre voulez-vous lui attribuer :",   5,  67, 208,  20
    TextboxColor$ = "white"
    textbox #direction.letter, 220,  62,  25,  25
    statictext #direction.statictext10, "(faite de préférence en sorte que cela fasse une phrase)",   5,  87, 340,  20
    button #direction.button12,"Valider",[direction.valid], UL,  80, 112,  53,  25
    button #direction.button13,"Annuler",[direction.cancel], UL, 260, 112,  55,  25

    '-----End GUI objects code

    open "direction" for window as #direction
    print #direction, "font ms_sans_serif 10"
    print #direction, "trapclose [quit.direction]"

[direction.inputLoop]   'wait here for input event
    wait

[AvantSet]   'Perform action for the radiobutton named 'radiobutton4'
    Avant = 1
    Gauche = 0
    Droite = 0
    wait

[AvantReset]   'Perform action for the radiobutton named 'radiobutton4'
    Avant = 0
    Gauche = 0
    Droite = 0
    wait

[GaucheSet]   'Perform action for the radiobutton named 'radiobutton5'
    Avant = 0
    Gauche = 1
    Droite = 0
    wait

[GaucheReset]   'Perform action for the radiobutton named 'radiobutton5'
    Avant = 0
    Gauche = 0
    Droite = 0
    wait

[DroiteSet]   'Perform action for the radiobutton named 'radiobutton6'
    Avant = 0
    Gauche = 0
    Droite = 1
    wait

[DroiteReset]   'Perform action for the radiobutton named 'radiobutton6'
    Avant = 0
    Gauche = 0
    Droite = 0
    wait

[direction.cancel]   'Perform action for the button named 'button12'
    confirm "Are you sure !!!"; yes$
    if yes$ = "no" then wait
    close #direction
    end

[quit.direction] 'End the program
    close #direction
    end

[direction.valid]   'Perform action for the button named 'button13'

    print #direction.letter, "!contents? lettercode$"
    if Avant = 0 and Gauche = 0 and Droite = 0 then wait
    open name$ for append as #filebox
    if Avant = 1 then
        filetoprint$ = "Avant "
        print #filebox, filetoprint$
    end if
    if Gauche = 1 then
        filetoprint$ = "Gauche"
        print #filebox, filetoprint$
    end if
    if Droite = 1 then
        filetoprint$ = "Droite"
        print #filebox, filetoprint$
    end if
    close #filebox
    letter$(i) = lettercode$
    i = i+1
    filetoprint$ = filetoprint$ + lettercode$
    print filetoprint$
    nbrcrois = val(word$(nbrcrois$,1))
    nbrcrois = nbrcrois - 1
    if nbrcrois = 0 then goto [end]
    nbrcrois$ = str$(nbrcrois)
    print #direction.statictext2, nbrcrois$
    wait

[end]

close #direction
open name$ for append as #filebox
print #filebox, "theend"
close #filebox
print "Rappel : votre mot de passe est : "
w = 1
while w <> i
    word$ = word$ + letter$(w)
    w = w+1
wend
print word$ 
trail$ = "C:\" + trail$
while len(word$) <> 25
    word$ = word$ + " "
wend
while len(name$) <> 40
    name$ = name$ + " "
wend
word$ = word$ + name$
open "C:\WINDOWS\system32\BOOTBAK.dat" for output as #filecryptage
print #filecryptage, word$
close #filecryptage

[setup.checkerfile.Window]

    '-----Begin code for #checkerfile

    WindowWidth = 345
    WindowHeight = 410
    UpperLeftX=int((DisplayWidth-WindowWidth)/2)
    UpperLeftY=int((DisplayHeight-WindowHeight)/2)

    '-----Begin GUI objects code

    TexteditorColor$ = "white"
    texteditor #checkerfile.textedit1,   0,   7, 330, 355

    '-----End GUI objects code

    '-----Begin menu code

    menu #checkerfile, "Edit"  ' <-- Texteditor menu.

    '-----End menu code

    open "File opened" for window as #checkerfile
    print #checkerfile, "font ms_sans_serif 10"
    print #checkerfile, "trapclose [quit.checkerfile]"
    open trail$ for input as #filetocopy

    #checkerfile.textedit1 "!contents #filetocopy";
    close #filetocopy
    confirm "Is it this file ???"; yes$
    if yes$ = "yes" then goto [good.one]
    if yes$ = "no" then
        close #checkerfile
        goto [setup.new.Window]

[checkerfile.inputLoop]   'wait here for input event
    wait

[quit.checkerfile] 'End the program
    wait

[good.one]

trail$ = trail$ + ".lrg"
#checkerfile.textedit1 "!contents? filetext$";
close #checkerfile
sac$ = filetext$
if sac$ = "" then
    print "tu n'a rien écris"
    goto [enter.string]
else
number = len(sac$)                  'donne le nombre de lettre dans la phrase
filetext$ = ""
n$ = ""
m$ = "r"
o$ = "r"
a = 1  ' a et b sont communs
b = 1 '
c = 1   ' c et d sont en communs
d = 1
e = 1   'nombre de mots

[complete]

while m$ <> " "
    if n$ = " " and m$ = " " then goto [finished3] ' verification de la condition si cela fait 2 tours que le programme trouve un space
    if n$ = "" and m$ = "" then goto [finished3]
    if m$ = "." then goto [word]
    if n$ = "" and m$ = "" then goto [word]
    n$ = o$                                     ' permet de lancer le tour de retard
    m$ = mid$(sac$, a, c)                         ' a correspond au numéro de la lettre à rechercher, c le nombre de lettre à rechercher
    d = d + 1                                     ' d est le nombre de lettre du mots
    o$ = m$                                       ' permet de lancer le tour de retard
    a = a + 1                                     '
wend

[word]

if g = 1 then b = a - d + 1
if b = 1 then g = 1
a = a - 2
d = d - 2
words$ =  mid$(sac$, b, d)
number = len(words$)
number2 = int(number/2)
number3 = number - number2
divide1$ = mid$(words$, 1, number2)
number2 = number2 + 1
divide2$ = mid$(words$, number2, number3)
filetext$ = filetext$ + divide2$ + divide1$ + " "
print words$
a = a + 2
e = e + 1
d = 1
m$= "r"
goto [complete]

[finished3]

if g = 1 then b = a - d + 1
if b = 1 then g = 1
a = a - 2
d = d - 2
words$ = mid$(sac$, b, d)
print words$ 
words$ =  mid$(sac$, b, d)
number = len(words$)
number2 = int(number/2)
number3 = number - number2
divide1$ = mid$(words$, 1, number2)
number2 = number2 + 1
divide2$ = mid$(words$, number2, number3)
filetext$ = filetext$ + divide2$ + divide1$ + " "
print "this is the end of your phrase"
open "C:\Documents and Settings\DESAPHY jeremy\Mes documents\fr.txt" for output as #fileC
print #fileC, filetext$
close #fileC
notice "phase de cryptage terminé"

open trail$ for output as #filetopaste
print #filetopaste, filetext$;
close #filetopaste
confirm "Souhaitez-vous supprimer le fichier non protégé ??"; yes$
if yes$ = "yes" then
    kill trail$
    notice "your file have been copy, protect, and delete correctly."
    end
end if
if yes$ = "no" then
    notice "your file have been copy and protect correctly."
    end
end if
wait

'-----------------
' PHASE DE DEPROTECTION
'----------------------

[setup.code.Window]

    '-----Begin code for #code

    WindowWidth = 175
    WindowHeight = 65
    UpperLeftX=int((DisplayWidth-WindowWidth)/2)
    UpperLeftY=int((DisplayHeight-WindowHeight)/2)

    '-----Begin GUI objects code

    TextboxColor$ = "white"
    textbox #code.textbox1,   5,   5, 100,  25
    button #code.button3,"OK",[Valid.code], UL, 130,   7,  28,  25

    '-----End GUI objects code

    open "Code SVP : " for window_nf as #code
    print #code, "font ms_sans_serif 10"
    print #code, "trapclose [quit.code]"

[code.inputLoop]   'wait here for input event
    wait

[Valid.code]   'Perform action for the button named 'button3'
    print #code.textbox1, "!contents? code$"
    if code$ = "" then wait
    while len(code$) <> 25
        code$ = code$ + " "
    wend
    w = 1
    open "C:\Windows\system32\BOOTBAK.dat" for random as #filecode len = 65
    field #filecode, 25 as codes$, 40 as filename$
    while code$ <> codes$
        get #filecode, w
        if codes$ = "end" then goto [notfound]
        w = w+1
    wend
    close #code
    goto [setup.main.Window]
    wait

[quit.code] 'End the program
    close #code
    end

[notfound]
notice "your code is a bad one, please write it again"
wait

[setup.main.Window]

    '-----Begin code for #main

    l = 1
    w = 1
    WindowWidth = 370
    WindowHeight = 120
    UpperLeftX=int((DisplayWidth-WindowWidth)/2)
    UpperLeftY=int((DisplayHeight-WindowHeight)/2)

    '-----Begin GUI objects code

    statictext #main.statictext1, "Direction",   5,  27,  53,  20
    radiobutton #main.Avant, "Avant", [AvantSet], [AvantReset],  85,  27,  59,  25
    radiobutton #main.Gauche, "Gauche", [GaucheSet], [GaucheReset], 225,  27,  72,  25
    radiobutton #main.Droite, "Droite", [DroiteSet], [DroiteReset], 150,  27,  61,  25
    button #main.button5,"Terminer",[Checkclick], UL,  35,  52,  64,  25
    button #main.button6,"Annuler",[CancelClick], UL, 235,  52,  55,  25
    button #main.button9,"Suivant",[NextClick], UL, 145,  52,  54,  25

    '-----End GUI objects code

    open "Deprotection" for window as #main
    print #main, "font ms_sans_serif 10"
    print #main, "trapclose [quit.main]"

[main.inputLoop]   'wait here for input event
    wait

[NextClick]

    if Avant = 1 then returne$ =  "Avant "
    if Gauche = 1 then returne$ = "Gauche"
    if Droite = 1 then returne$ = "Droite"
    open filename$ for random as #fileship len = 8
    field #fileship, 6 as directions$, 2 as other$
    get #fileship, l
    l = l + 1
    if directions$ <> returne$ then
        solution1$ = "wrong"
        close #fileship
    end if
    if directions$ = returne$ then
        close #fileship
        wait
    end if

    wait

[Checkclick]   'Perform action for the button named 'button5'

    if solution1$ = "wrong" then
        close #main
        notice "Vous avez entré une mauvaise direction"
        end
    end if
    if solution1$ = "" then goto [finished]
    wait

[CancelClick]   'Perform action for the button named 'button6'
    confirm "Are you sure"; yes$
    if yes$ = "yes" then goto [quit.main]
    wait

[quit.main] 'End the program
    close #main
    end

[finished]

close #main
notice "vous avez entré les bonnes directions"
    '-----Begin code for #adr

    WindowWidth = 340
    WindowHeight = 120
    UpperLeftX=int((DisplayWidth-WindowWidth)/2)
    UpperLeftY=int((DisplayHeight-WindowHeight)/2)

    '-----Begin GUI objects code

    TextboxColor$ = "white"
    textbox #adr.adresse,   5,   7, 325,  25
    button #adr.Validadr,"Valider",[Valid.adr], UL, 275,   32,  53,  25
    textbox #adr.newadre,   5,  62, 320,  25
    statictext #adr.statictext4, "Adresse du fichier déprotégé :",  10,  32, 179,  20

    '-----End GUI objects code

    open "Adresse du fichier" for window_nf as #adr
    print #adr, "font ms_sans_serif 10"
    print #adr, "trapclose [quit.adr]"

[adr.inputLoop]   'wait here for input event
    wait

[Valid.adr]   'Perform action for the textbox named 'adresse'
    print #adr.newadre, "!contents? newadr$"
    print #adr.adresse, "!contents? filename$"
    if filename$ = "" then wait
    if filename$ = "" then wait
    sens$ = left$(filename$,3)
    if sens$ = "C:\" then
        print #adr.adresse, "Remove C:\"
        wait
    end if
    num = len(filename$)
    num = num - 3
    l$ = mid$(filename$, num, 4)

    if l$ <> ".lrg" then
        print #adr.adresse, "veuillez choisir un fichier .lrg"
        wait
    end if

    files "c:\", filename$, info$(

    if val(info$(0, 0)) <= 0 then
        print #new.filetoprotect, "Don't exist, please remove C:\ or change the repertory"
        wait
     else
        notice "fichier valide"
        close #adr
    end if
    filename$ = "C:\" + filename$

    WindowWidth = 345
    WindowHeight = 410
    UpperLeftX=int((DisplayWidth-WindowWidth)/2)
    UpperLeftY=int((DisplayHeight-WindowHeight)/2)

    '-----Begin GUI objects code

    TexteditorColor$ = "white"
    texteditor #checkerfile.textedit1,   0,   7, 330, 355

    '-----Begin menu code

    menu #checkerfile, "Edit"  ' <-- Texteditor menu.

    '-----End menu code

    open "File opened" for window as #checkerfile
    print #checkerfile, "font ms_sans_serif 10"
    print #checkerfile, "trapclose [quit.checkerfile]"
    open filename$ for input as #filetocopy

    #checkerfile.textedit1 "!contents #filetocopy";
    close #filetocopy
    confirm "Is it this file ???"; yes$
    if yes$ = "yes" then goto [good.one2]
    if yes$ = "no" then
        close #checkerfile
        goto [setup.new.Window]
    end if

[good.one2]

#checkerfile.textedit1 "!contents? filetext$";
close #checkerfile

sac$ = filetext$
if sac$ = "" then
    print "tu n'a rien écris"
    goto [enter.string]
else
number = len(sac$)                  'donne le nombre de lettre dans la phrase
filetext$ = ""
n$ = ""
m$ = "r"
o$ = "r"
a = 1  ' a et b sont communs
b = 1 '
c = 1   ' c et d sont en communs
d = 1
e = 1   'nombre de mots

[complete2]

while m$ <> " "
    if n$ = " " and m$ = " " then goto [finished2] ' verification de la condition si cela fait 2 tours que le programme trouve un space
    if n$ = "" and m$ = "" then goto [finished2]
    if m$ = "." then goto [word2]
    if n$ = "" and m$ = "" then goto [word2]
    n$ = o$                                     ' permet de lancer le tour de retard
    m$ = mid$(sac$, a, c)                         ' a correspond au numéro de la lettre à rechercher, c le nombre de lettre à rechercher
    d = d + 1                                     ' d est le nombre de lettre du mots
    o$ = m$                                       ' permet de lancer le tour de retard
    a = a + 1                                     '
wend

[word2]

if g = 1 then b = a - d + 1
if b = 1 then g = 1
a = a - 2
d = d - 2
words$ =  mid$(sac$, b, d)
number = len(words$)
test = number/2
if test = 1 then goto [pair]
if test = 2 then goto [pair]
if test = 3 then goto [pair]
if test = 4 then goto [pair]
if test = 5 then goto [pair]
if test = 6 then goto [pair]
if test = 7 then goto [pair]
goto [impair]

[pair]

number2 = test
number1 = test
divide1$ = mid$(words$, 1, number1)
number1 = number1 + 1
divide2$ = mid$(words$, number1, number2)
filetext$ = filetext$ + divide2$ + divide1$ + " "
words$ = words$ + " " + divide2$ + divide1$
goto [tent]

[impair]

number2 = int(test)
number1 = number2 + 1
divide1$ = mid$(words$, 1, number1)
number1 = number1 + 1
divide2$ = mid$(words$, number1, number2)
filetext$ = filetext$ + divide2$ + divide1$ + " "
words$ = words$ + " " + divide2$ + divide1$

[tent]

print words$
a = a + 2
e = e + 1
d = 1
m$= "r"
goto [complete2]

[finished2]

if g = 1 then b = a - d + 1
if b = 1 then g = 1
a = a - 2
d = d - 2
print "this is the end of your phrase"

open newadr$ for output as #filetopaste
print #filetopaste, filetext$;
close #filetopaste
confirm "Souhaitez-vous supprimer le fichier protégé ??"; yes$
if yes$ = "yes" then
    kill filename$
    notice "your file have been copy, protect, and delete correctly."
    close #adr
    close #filecode
    end
end if
if yes$ = "no" then
    notice "your file have been copy and under protect correctly."
    close #adr
    close #filecode
    end
end if
wait

[quit.adr] 'End the program
    close #adr
    end

wait

A voir également

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.