79331358

Date: 2025-01-05 19:00:36
Score: 1
Natty:
Report link

All right guys, this is my answer based on your comments, now fully functional. Thanks a lot: enter image description here

//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, substr(prepare_key($encryption_key),0,10), $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, substr(prepare_key($encryption_key),0,10), $tag);
        var_dump("dumpfn:".openssl_decrypt($encrypted, $method, prepare_key($encryption_key), $options=0, $iv, $tag));
        echo("<br>");
        var_dump("encr:".$encrypted);
        echo("<br>");
        var_dump("decr:".$decrypted);
        echo("<br>");
        return $decrypted;
    }
Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Probably link only (1):
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Lesna Vevericka