Jump to content

Question about crypting online resource.

Recommended Posts

In the past with old PHP i was using mcrypt ... but i guess its not anymore avaliable on php 8 and, since Last ISP suite works with newer php, i need to update this too.


that old code.

function addpadding($string, $blocksize = 32)
    $len = strlen($string);
    $pad = $blocksize - ($len % $blocksize);
    $string .= str_repeat(chr($pad), $pad);
    return $string;

function strippadding($string)
    $slast = ord(substr($string, -1));
    $slastc = chr($slast);
    $pcheck = substr($string, -$slast);
    if(preg_match("/$slastc{".$slast."}/", $string)){
    $string = substr($string, 0, strlen($string)-$slast);
        return $string;
    } else {
        return false;

function MCryptEncrypt ($string,$key,$iv)
    return base64_encode(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, addpadding($string), MCRYPT_MODE_CBC, $iv)));

function MCryptDecrypt($string,$key,$iv)
    $string = base64_decode(base64_decode($string));
    return strippadding(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $string, MCRYPT_MODE_CBC, $iv));




this work trough c++ application is there something of same also for php 8 ?

P.s im not using open ssl on c++ just wrote from scratch the whole AeS CBC.

using this to encrypt comunication from client to server, and server to client.

Edited by GHTheBoss
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...