Il existe quelques variantes de cette question, mais je n'ai pas été en mesure d'épingler le problème. Essayer de crypter/décrypter en PHP et Delphi Je suppose que je l'ai manqué quelques réglages à Delphes et son rapport avec UTF-8Delphi/PHP LockBox Encryption AES ECB
en utilisant http://aesencryption.net/ comme PHP Exemple le résultat que nous essayons d'obtenir. Image Coup
Password = 123
Key = Test
128 bits
Crypte à uuIikEZSC9Sa1HAt/XKfGQ ==
Je veux être en mesure de déchiffrer ce Delphi
J'utilise Delphi XE5
avec https://github.com/SeanBDurkin/tplockbox
je peux obtenir chiffrer/décrypter travailler à l'intérieur Delphi, mais la chaîne de version cryptée PHP est différent
Delphi crypte 123 à vpdeLlfnxTGrSsa2TpbFvg ==
Voici un exemple rapide de Delphi Crypter
function TForm3.EncryptV2(plainText: UTF8String): String;
var CipherText : string;
FLibrary: TCryptographicLibrary;
FCodec: TCodec;
begin
mmo1.Lines.Add('plaintext = ' + plainText);
FLibrary := TCryptographicLibrary.Create(Self);
try
FCodec := TCodec.Create(Self);
try
FCodec.CryptoLibrary := FLibrary;
FCodec.StreamCipherId := BlockCipher_ProgId;
FCodec.BlockCipherId := Format(AES_ProgId, [256]);
FCodec.ChainModeId := ECB_ProgId; ;
FCodec.UTF8Password := 'test';
FCodec.EncryptString(plainText, CipherText, Tencoding.UTF8);
FCodec.Burn;
result := CipherText;
finally
FCodec.Free;
end;
finally
FLibrary.Free;
end;
end;
Décrypter
function TForm3.DecryptV2(encryptedText: UTF8String): String;
var plainText : string;
FLibrary: TCryptographicLibrary;
FCodec: TCodec;
begin
FLibrary := TCryptographicLibrary.Create(Self);
try
FCodec := TCodec.Create(Self);
try
FCodec.CryptoLibrary := FLibrary;
FCodec.StreamCipherId := BlockCipher_ProgId;
FCodec.BlockCipherId := Format(AES_ProgId, [256]);
FCodec.ChainModeId := ECB_ProgId; ;
FCodec.UTF8Password := 'test';
mmo1.Lines.Add('Encrypted Text = ' + encryptedText);
FCodec.DecryptString(plainText, encryptedText,Tencoding.UTF8);
mmo1.Lines.Add('DeCrypted Text = ' + plainText);
result := plainText;
finally
FCodec.Free;
end;
finally
FLibrary.Free;
end;
end;
Quelqu'un at-il des suggestions?
S'il vous plaît ne pas utiliser aesencryption.net comme référence pour le chiffrement, car il utilise un mauvais mode de (BCE), un mauvais remplissage (padding zéro) et ne prend pas en charge l'authentification . –
** N'utilisez jamais [mode ECB] (http://crypto.stackexchange.com/q/14487/13022) **. C'est déterministe et donc pas sémantiquement sécurisé. Vous devriez à tout le moins utiliser un mode aléatoire comme [CBC] (http://crypto.stackexchange.com/q/22260/13022) ou [CTR] (http://crypto.stackexchange.com/a/2378/ 13022). Il est préférable d'authentifier vos textes chiffrés afin que les attaques comme une [attaque oracle padding] (http://crypto.stackexchange.com/q/18185/13022) ne soient pas possibles. Cela peut être fait avec des modes authentifiés comme GCM ou EAX, ou avec un schéma [encrypt-then-MAC] (http://crypto.stackexchange.com/q/202/13022). –
Je ne pouvais pas obtenir Cbc ou d'autres pour correspondre non plus. Je pense que j'essaierais de commencer par le plus simple puis de voir si c'est la même raison que les autres ne correspondent pas – Dangas56