Decrypt/Encrypte sur un String
Bonjour tout le monde
Je sais bien que ce sujet à déjà été discuté mais là je rencontre un problème.
Si j'ai un string qui dépasse 255 caractères la procédure de cryptage me fait n'importe quoi !!!
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| function TForm1.CryptDeCrypt(St:string;Key:integer;Decalage:Byte):string;
var
i :byte;
StCrypt:string;
begin
StCrypt:='';
for i:=1 to Length(St) do
StCrypt:= StCrypt + Char(Byte(St[i]) xor Key shr Decalage); le cryptage
result:=StCrypt;
end;
procedure TForm1.Button1Click(Sender: TObject);
Var
str : String;
begin
Str := 'DPrincipal::FPrincipal;';
Str := Str + 'DTaches::FTaches;';
Str := Str + 'DFichiersClients::FFichiersClients;';
Str := Str + 'DFichiersRessources::FFichiersRessources;';
Str := Str + 'DFichiersEquipes::FFichiersEquipes;';
Str := Str + 'DFichiersCategories::FFichiersCategories;';
Str := Str + 'DFichiersObjets::FFichiersObjets;';
// Str := Str + 'DFichiersCommunes::FFichiersCommunes;';
Memo2.Text := CryptDeCrypt(Str,10500,6);
Memo3.Text := CryptDeCrypt(Memo2.Text,10500,6);
end; |
Cela paraît super bête, mais cela ne marche super pas... dés que je dépasse les 255 le result est faux et ne correspond en rien à ce que j'attends.
Où est l'erreur ?