Aşağıda örnek kodu paylaştığım PHP de aslında tek satırda bu işin ne kadar kolay olduğunu göreceksiniz. Şimdilik bunu kullanarak Delphi tarafına json olarak aktarıyorum ama bu çözümü kullanmak da istemiyorum. Delphi tarafında gerek forumda gerekse nette yaptığım araştırmalarda elde ettiğim kodların hiçbirisi bana nedense doğru çözümü vermedi. Denediğim kodlar bir türlü doğru şifreleme yapmıyor. AES-256-ECB olarak aşağıdaki gibi bana doğru şifreleme yapacak Delphi kodu aramaya devam ediyorum. Netice elde edebilirsem bunu da paylaşacağım.
function encrypt( $key, $plain ) {
echo "\n iv=\t\t(binary as hex)\t". bin2hex( $iv ). "\tlength=". strlen( $iv );
// By default OpenSSL already returns Base64, but it could be changed
// to binary with the 4th parameter, if we want.
$iv= '';
$encryptedData= base64_encode ( openssl_encrypt( $plain, CIPHER, $key, $options=OPENSSL_RAW_DATA, $iv) );
echo "\n encrypted=\t(Base64)\t". $encryptedData;
// The encrypted data already came in Base64 - no need to encode it
// again in Base64. Just concatenate it with the initialization
// vector, which is the only part that should also be encoded to
// Base64. And now we have a 7bit-safe ASCII text, which could be
// easily inserted into emails.
return $encryptedData;
}
function encrypt( $key, $plain ) {
echo "\n iv=\t\t(binary as hex)\t". bin2hex( $iv ). "\tlength=". strlen( $iv );
// By default OpenSSL already returns Base64, but it could be changed
// to binary with the 4th parameter, if we want.
$iv= '';
$encryptedData= base64_encode ( openssl_encrypt( $plain, CIPHER, $key, $options=OPENSSL_RAW_DATA, $iv) );
echo "\n encrypted=\t(Base64)\t". $encryptedData;
// The encrypted data already came in Base64 - no need to encode it
// again in Base64. Just concatenate it with the initialization
// vector, which is the only part that should also be encoded to
// Base64. And now we have a 7bit-safe ASCII text, which could be
// easily inserted into emails.
return $encryptedData;
}
Ne ekersen onu biçersin!

