public function decryptMessage($message)
    {
        $calgo = $this->config->getCipherAlgorithm();
        $cmode = $this->config->getCipherMode();
        $malgo = $this->config->getHmacAlgorithm();
        
        $size = mcrypt_get_iv_size($calgo, $cmode);
        $keySize = mcrypt_get_key_size($calgo, $cmode);
        $hmacSize = strlen(hash_hmac($malgo, '', 'foo-key', true));

        $cmac = substr($message, -1 * $hmacSize);
        $iv = substr($message, 0, $size);
        $cipherText = substr($message, $size, -1 * $hmacSize);
        $hmac = hash_hmac($malgo, $iv . $cipherText, $this->computeCipherKey($this->config->getHmacKey(), $hmacSize, $iv), true);
        
        if(!SecurityUtil::timingSafeEquals($hmac, $cmac))
        {
            throw new IntegrityCheckFailedException('Invalid encrypted input message detected');
        }
        
        $key = $this->computeCipherKey($this->config->getCipherKey(), $keySize, $iv);
        $data = mcrypt_decrypt($calgo, $key, $cipherText, $cmode, $iv);
        
        // PKCS7 Padding
        $pad = ord($data[strlen($data) - 1]);
        $data = substr($data, 0, -1 * $pad);
        
        // Remove zero-byte padding from the string.
        return $data;
    }
public function decryptMessage($message)
    {
        $calgo = $this->config->getCipherAlgorithm();
        $cmode = $this->config->getCipherMode();
        $malgo = $this->config->getHmacAlgorithm();
        
        $size = mcrypt_get_iv_size($calgo, $cmode);
        $keySize = mcrypt_get_key_size($calgo, $cmode);
        $hmacSize = strlen(hash_hmac($malgo, '', 'foo-key', true));

        $cmac = substr($message, -1 * $hmacSize);
        $iv = substr($message, 0, $size);
        $cipherText = substr($message, $size, -1 * $hmacSize);
        $hmac = hash_hmac($malgo, $iv . $cipherText, $this->computeCipherKey($this->config->getHmacKey(), $hmacSize, $iv), true);
        
        if(!SecurityUtil::timingSafeEquals($hmac, $cmac))
        {
            throw new IntegrityCheckFailedException('Invalid encrypted input message detected');
        }
        
        $key = $this->computeCipherKey($this->config->getCipherKey(), $keySize, $iv);
        $data = mcrypt_decrypt($calgo, $key, $cipherText, $cmode, $iv);
        
        // PKCS7 Padding
        $pad = ord($data[strlen($data) - 1]);
        $data = substr($data, 0, -1 * $pad);
        
        // Remove zero-byte padding from the string.
        return $data;
    }
public function decryptMessage ( $ message ) { $ calgo = $ this -> config -> getCipherAlgorithm ( ) ; $ cmode = $ this -> config -> getCipherMode ( ) ; $ malgo = $ this -> config -> getHmacAlgorithm ( ) ; $ size = mcrypt_get_iv_size ( $ calgo , $ cmode ) ; $ keySize = mcrypt_get_key_size ( $ calgo , $ cmode ) ; $ hmacSize = strlen ( hash_hmac ( $ malgo , '' , 'foo-key' , true ) ) ; $ cmac = substr ( $ message , - 1 * $ hmacSize ) ; $ iv = substr ( $ message , 0 , $ size ) ; $ cipherText = substr ( $ message , $ size , - 1 * $ hmacSize ) ; $ hmac = hash_hmac ( $ malgo , $ iv . $ cipherText , $ this -> computeCipherKey ( $ this -> config -> getHmacKey ( ) , $ hmacSize , $ iv ) , true ) ; if ( ! SecurityUtil :: timingSafeEquals ( $ hmac , $ cmac ) ) { throw new IntegrityCheckFailedException ( 'Invalid encrypted input message detected' ) ; } $ key = $ this -> computeCipherKey ( $ this -> config -> getCipherKey ( ) , $ keySize , $ iv ) ; $ data = mcrypt_decrypt ( $ calgo , $ key , $ cipherText , $ cmode , $ iv ) ; // PKCS7 Padding
 $ pad = ord ( $ data [ strlen ( $ data ) - 1 ] ) ; $ data = substr ( $ data , 0 , - 1 * $ pad ) ; // Remove zero-byte padding from the string.
 return $ data ; }
Decrypts a message with auhtenticity check.

@param string $message Encoded message.
@return mixed Plaintext message.

@throws IntegrityCheckFailedException
Decrypts a message with auhtenticity check .