common.php
public static function OpensslDecrypt($ciphertext,$key){
        $c = base64_decode($ciphertext);
        $ivlen = openssl_cipher_iv_length($cipher="BF-CBC");
        $iv = substr($c, 0, $ivlen);
        $hmac = substr($c, $ivlen, $sha2len=32);
        $ciphertext_raw = substr($c, $ivlen+$sha2len);
        $original_plaintext = openssl_decrypt($ciphertext_raw, $cipher, $key, $options=OPENSSL_RAW_DATA, $iv);
        $calcmac = hash_hmac('sha256', $ciphertext_raw, $key, $as_binary = true);
        if (hash_equals($hmac, $calcmac))//PHP 5.6+
        {
            return $original_plaintext;
        }
    }
public static function OpensslDecrypt($ciphertext,$key){
        $c = base64_decode($ciphertext);
        $ivlen = openssl_cipher_iv_length($cipher="BF-CBC");
        $iv = substr($c, 0, $ivlen);
        $hmac = substr($c, $ivlen, $sha2len=32);
        $ciphertext_raw = substr($c, $ivlen+$sha2len);
        $original_plaintext = openssl_decrypt($ciphertext_raw, $cipher, $key, $options=OPENSSL_RAW_DATA, $iv);
        $calcmac = hash_hmac('sha256', $ciphertext_raw, $key, $as_binary = true);
        if (hash_equals($hmac, $calcmac))//PHP 5.6+
        {
            return $original_plaintext;
        }
    }
public static function OpensslDecrypt ( $ ciphertext , $ key ) { $ c = base64_decode ( $ ciphertext ) ; $ ivlen = openssl_cipher_iv_length ( $ cipher = "BF-CBC" ) ; $ iv = substr ( $ c , 0 , $ ivlen ) ; $ hmac = substr ( $ c , $ ivlen , $ sha2len = 32 ) ; $ ciphertext_raw = substr ( $ c , $ ivlen + $ sha2len ) ; $ original_plaintext = openssl_decrypt ( $ ciphertext_raw , $ cipher , $ key , $ options = OPENSSL_RAW_DATA , $ iv ) ; $ calcmac = hash_hmac ( 'sha256' , $ ciphertext_raw , $ key , $ as_binary = true ) ; if ( hash_equals ( $ hmac , $ calcmac ) ) //PHP 5.6+
 { return $ original_plaintext ; } }
openssl decrypt
openssl decrypt