-
- {déclarations}
-
-
- interface
-
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, Borland.Vcl.StdCtrls, System.ComponentModel;
-
- function crypter(chainetocrypt: String; cryptkey: String): string;
- Function decrypter(chainetodecrypt: String; cryptkey: String): String;
-
- {fonctions}
- function crypter(chainetocrypt: String; cryptkey :String) :string;
- var
- crypte: String;
- cpt,i: longint ;
- begin
- crypter := '';
- cpt := 1;
- For i := 1 To Length(chainetocrypt) do
- begin
- If cpt > Length(cryptkey) Then cpt := 1;
- If integer(ord(chainetocrypt[i])) + integer(ord(cryptkey[cpt])) > 255 Then {on vérifie que la some du code ascii ne soit pas supérieur a 255 sinon erreu}
- result := result + Char((integer(ord(chainetocrypt[i])) + integer(ord(cryptkey[cpt]))) - 255) {'si c'est le cas on enlève 255}
- Else
- result := result + Char(integer(ord(chainetocrypt[i])) + integer(ord(cryptkey[cpt]))); {'on ajoute le caractère crypté a la fonction}
-
- cpt := cpt + 1;
- end;
-
- End;
-
- Function decrypter(chainetodecrypt: String; cryptkey: String):String;
- var
- crypte: String;
- cpt,i: longint ;
- begin
- decrypter := '';
- cpt := 1;
- For i := 1 To Length(chainetodecrypt) do
- begin
- If cpt > Length(cryptkey) Then cpt := 1;
- If (integer(ord(chainetodecrypt[i])) - integer(ord(cryptkey[cpt]))) < 0 Then {'on vérifie que la some du code ascii ne soit pas inférieur a 0 sinon erreur}
- result := result + Char((integer(ord(chainetodecrypt[i])) - integer(ord(cryptkey[cpt]))) + 255) {'si c'est le cas on ajoute 255}
- Else
- result := result + Char(integer(ord(chainetodecrypt[i])) - integer(ord(cryptkey[cpt]))); {'on ajoute le caractère décrypté a la fonction}
-
- cpt := cpt + 1;
- end;
- End;
{déclarations}
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Borland.Vcl.StdCtrls, System.ComponentModel;
function crypter(chainetocrypt: String; cryptkey: String): string;
Function decrypter(chainetodecrypt: String; cryptkey: String): String;
{fonctions}
function crypter(chainetocrypt: String; cryptkey :String) :string;
var
crypte: String;
cpt,i: longint ;
begin
crypter := '';
cpt := 1;
For i := 1 To Length(chainetocrypt) do
begin
If cpt > Length(cryptkey) Then cpt := 1;
If integer(ord(chainetocrypt[i])) + integer(ord(cryptkey[cpt])) > 255 Then {on vérifie que la some du code ascii ne soit pas supérieur a 255 sinon erreu}
result := result + Char((integer(ord(chainetocrypt[i])) + integer(ord(cryptkey[cpt]))) - 255) {'si c'est le cas on enlève 255}
Else
result := result + Char(integer(ord(chainetocrypt[i])) + integer(ord(cryptkey[cpt]))); {'on ajoute le caractère crypté a la fonction}
cpt := cpt + 1;
end;
End;
Function decrypter(chainetodecrypt: String; cryptkey: String):String;
var
crypte: String;
cpt,i: longint ;
begin
decrypter := '';
cpt := 1;
For i := 1 To Length(chainetodecrypt) do
begin
If cpt > Length(cryptkey) Then cpt := 1;
If (integer(ord(chainetodecrypt[i])) - integer(ord(cryptkey[cpt]))) < 0 Then {'on vérifie que la some du code ascii ne soit pas inférieur a 0 sinon erreur}
result := result + Char((integer(ord(chainetodecrypt[i])) - integer(ord(cryptkey[cpt]))) + 255) {'si c'est le cas on ajoute 255}
Else
result := result + Char(integer(ord(chainetodecrypt[i])) - integer(ord(cryptkey[cpt]))); {'on ajoute le caractère décrypté a la fonction}
cpt := cpt + 1;
end;
End;