0

I have a problem with my function that encrypts the data. There's my function that encrypt the data:

$key = "tHeApAcHe6410111";

function encrypt($text,$key){
  $block = mcrypt_get_block_size('rijndael_128', 'ecb');
  $pad = $block - (strlen($text) % $block);
  $text .= str_repeat(chr($pad), $pad);
  return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $text, MCRYPT_MODE_ECB));
}

In the end, I output what was encrypted:

$enc =  encrypt("test",$GLOBALS['key']);
echo "Encrypt: " . $enc . "</br>";

But, what I get as output is the following:

Fatal error: Uncaught Error: Call to undefined function openssl_cipher_iv_length() in C:\ServidorWeb\htdocs\encriptacao.php:8 Stack trace: #0 C:\ServidorWeb\htdocs\encriptacao.php(60): openssl_cipher_block_length('rijndael_128', 'ecb') #1 C:\ServidorWeb\htdocs\encriptacao.php(92): encrypt('test', 'tHeApAcHe641011...') #2 {main} thrown in C:\ServidorWeb\htdocs\encriptacao.php on line 8

Does anyone know what may be happening?

Phil
  • 157,677
  • 23
  • 242
  • 245
Maria Dias
  • 11
  • 1
  • 3
    Did you actually search the web for "Call to undefined function openssl_cipher_iv_length"? I'm seeing a fair number of results when i do that. Was none of that helpful? – Mike 'Pomax' Kamermans Mar 23 '20 at 23:31
  • Yes, i did... But i can't solve. – Maria Dias Mar 23 '20 at 23:31
  • 2
    That's not detailed enough. What did you find, and then what did you already try? Because https://stackoverflow.com/questions/27950428/call-to-undefined-function-openssl-decrypt certainly sounds like it would be the solution to this particular problem. – Mike 'Pomax' Kamermans Mar 23 '20 at 23:32
  • Well, how i do that in a web server? Where's c:/php on webserver? – Maria Dias Mar 23 '20 at 23:34
  • 3
    It's _your_ web server, you are the only one who can answer that question, given that you set it up? (and if you did not, [explain the actual setup and all other relevant details](/help/how-to-ask)) – Mike 'Pomax' Kamermans Mar 23 '20 at 23:34
  • Whatever shim your using to attempt to get mcrypt functions back isn't working because OpenSSL isn't installed, and even if it _was_ Rijndael doesn't work in OpenSSL. – Sammitch Mar 23 '20 at 23:44

0 Answers0