How to install and run Ossn 5.2 on PHP 7.4

We became aware that 2 functions of Ossn are no longer compatible with PHP 7.4

Hence, before uploading Ossn to your server and starting the installation you need to apply 2 fixes this way:

  • Unzip the ossn-v5.2-1577836800.zip archive locally on your PC
  • enter the directory ossn-v5.2-1577836800/libraries
  • Use a simple text-editor like Notepad++ and open ossn.lib.system.php
  • Scroll down to line 726 to find the following block of code

function ossn_string_encrypt($string = '', $key = '') {
if (empty($string)) {
    return false;
}
if (empty($key)) {
    $key = ossn_site_settings('site_key');
}

$key    = ossn_string_encrypt_key_cycled($key);
//string also need to be at least 16 bytes
$string = utf8_encode($string);
if (strlen($string) % 8) {
    $string = str_pad($string, strlen($string) + 8 - strlen($string) % 8, "\0");
}

$size    = openssl_cipher_iv_length('bf-ecb');
$mcgetvi = openssl_random_pseudo_bytes($size);
return trim(openssl_encrypt($string, "bf-ecb", $key, OPENSSL_RAW_DATA | OPENSSL_NO_PADDING, $mcgetvi)); 
}

  • delete this block completely and replace it by

function ossn_string_encrypt($string = '', $key = '') {
if (empty($string)) {
    return false;
}
if (strlen($string) % 8) {
    $string = str_pad($string, strlen($string) + 8 - strlen($string) % 8, "\0");
}
if (empty($key)) {
    $key = ossn_site_settings('site_key');
}
$key    = ossn_string_encrypt_key_cycled($key);
return openssl_encrypt($string, "bf-ecb", $key, OPENSSL_RAW_DATA | OPENSSL_NO_PADDING);
}   

  • scroll down a little further until you see

function ossn_string_decrypt($string = '', $key = '') {
if (empty($string)) {
    return false;
}
if (empty($key)) {
    $key = ossn_site_settings('site_key');
}
$key = ossn_string_encrypt_key_cycled($key);

$size    = openssl_cipher_iv_length('bf-ecb');
$mcgetvi = openssl_random_pseudo_bytes($size);
//note mcrypt and now this acting mcrpyt adds the spaces to make 16 bytes if its less then 16 bytes
//you can use trim() to get orignal data without spaces
return openssl_decrypt($string, "bf-ecb", $key, OPENSSL_RAW_DATA | OPENSSL_NO_PADDING, $mcgetvi);
      }

  • delete this block completely and replace it by

function ossn_string_decrypt($string = '', $key = '') {
if (empty($string)) {
    return false;
}
if (empty($key)) {
    $key = ossn_site_settings('site_key');
}
$key = ossn_string_encrypt_key_cycled($key);
return trim(openssl_decrypt($string, "bf-ecb", $key, OPENSSL_RAW_DATA  | OPENSSL_NO_PADDING));
      }

  • save your changes, leave the editor and start copying the files to your server

Please note that you would need to apply the same fixes BEFORE
updating any older PHP on your server to PHP 7.4