Anonymous
Почему простой тестовый шифр не работает в php8 на Manjaro Linux 24? Картина:
Сообщение
Anonymous » 05 янв 2025, 21:55
Код: Выделить всё
//pregenerate ciphers key
function prepare_key($encryption_key){
return openssl_digest($encryption_key, 'MD5', TRUE);
}
//literature manual: https://www.php.net/manual/en/function.openssl-encrypt.php
//function cipher string
function cipher_string($plaintext,$encryption_key){
$method=openssl_get_cipher_methods()[0];
$ivlen = openssl_cipher_iv_length($method);
$iv = openssl_random_pseudo_bytes($ivlen);
$encrypted = openssl_encrypt($plaintext, $method, prepare_key($encryption_key), $options=0, $iv, $tag);
return $encrypted;
}
//function to decipher string
function decipher_string($encrypted,$encryption_key){
$method=openssl_get_cipher_methods()[0];
$ivlen = openssl_cipher_iv_length($method);
$iv = openssl_random_pseudo_bytes($ivlen);
$decrypted = openssl_decrypt($encrypted, $method, prepare_key($encryption_key), $options=0, $iv, $tag);
var_dump("dumpfn:".openssl_decrypt($encrypted, $method, prepare_key($encryption_key), $options=0, $iv, $tag));
echo("
");
var_dump("encr:".$encrypted);
echo("
");
var_dump("decr:".$decrypted);
echo("
");
return $decrypted;
}
Ну, я использую этот код для шифрования текстов в php, и он не работает. Я что-то упускаю? Спасибо за любые подсказки.
Подробнее здесь:
https://stackoverflow.com/questions/793 ... ux-24-pict
1736103312
Anonymous
[img]https://i.sstatic.net/8QoSdrTK.png[/img] [code]//pregenerate ciphers key function prepare_key($encryption_key){ return openssl_digest($encryption_key, 'MD5', TRUE); } //literature manual: https://www.php.net/manual/en/function.openssl-encrypt.php //function cipher string function cipher_string($plaintext,$encryption_key){ $method=openssl_get_cipher_methods()[0]; $ivlen = openssl_cipher_iv_length($method); $iv = openssl_random_pseudo_bytes($ivlen); $encrypted = openssl_encrypt($plaintext, $method, prepare_key($encryption_key), $options=0, $iv, $tag); return $encrypted; } //function to decipher string function decipher_string($encrypted,$encryption_key){ $method=openssl_get_cipher_methods()[0]; $ivlen = openssl_cipher_iv_length($method); $iv = openssl_random_pseudo_bytes($ivlen); $decrypted = openssl_decrypt($encrypted, $method, prepare_key($encryption_key), $options=0, $iv, $tag); var_dump("dumpfn:".openssl_decrypt($encrypted, $method, prepare_key($encryption_key), $options=0, $iv, $tag)); echo(" "); var_dump("encr:".$encrypted); echo(" "); var_dump("decr:".$decrypted); echo(" "); return $decrypted; } [/code] Ну, я использую этот код для шифрования текстов в php, и он не работает. Я что-то упускаю? Спасибо за любые подсказки. Подробнее здесь: [url]https://stackoverflow.com/questions/79331094/why-is-simple-test-cipher-decipher-not-running-in-php8-on-manjaro-linux-24-pict[/url]