public static function verifyMessage($message, $key, $hashKey = '')
    {
        # Test the message and key for string validity.
        Helpers::isString($message, 'Encryption', 'verifyMessage');
        Helpers::isString($key, 'Encryption', 'verifyMessage');
        Helpers::isString($hashKey, 'Encryption', 'verifyMessage');

        # Create a special hashed key for encryption.
        $key = Hash::hash($key, $hashKey, Constants::AUTH_KEYBYTES);

        # Decode the message from JSON.
        $message = base64_decode(json_decode($message, true));

        if (\Sodium\crypto_auth_verify(Helpers::hex2bin($message['mac']), $message['msg'], $key)) {
            \Sodium\memzero($key);

            return $message['msg'];
        } else {
            \Sodium\memzero($key);
            throw new Exceptions\SignatureException('Signature for message invalid.');
        }
    }
public static function verifyMessage($message, $key, $hashKey = '')
    {
        # Test the message and key for string validity.
        Helpers::isString($message, 'Encryption', 'verifyMessage');
        Helpers::isString($key, 'Encryption', 'verifyMessage');
        Helpers::isString($hashKey, 'Encryption', 'verifyMessage');

        # Create a special hashed key for encryption.
        $key = Hash::hash($key, $hashKey, Constants::AUTH_KEYBYTES);

        # Decode the message from JSON.
        $message = base64_decode(json_decode($message, true));

        if (\Sodium\crypto_auth_verify(Helpers::hex2bin($message['mac']), $message['msg'], $key)) {
            \Sodium\memzero($key);

            return $message['msg'];
        } else {
            \Sodium\memzero($key);
            throw new Exceptions\SignatureException('Signature for message invalid.');
        }
    }
public static function verifyMessage ( $ message , $ key , $ hashKey = '' ) { # Test the message and key for string validity. Helpers :: isString ( $ message , 'Encryption' , 'verifyMessage' ) ; Helpers :: isString ( $ key , 'Encryption' , 'verifyMessage' ) ; Helpers :: isString ( $ hashKey , 'Encryption' , 'verifyMessage' ) ; # Create a special hashed key for encryption. $ key = Hash :: hash ( $ key , $ hashKey , Constants :: AUTH_KEYBYTES ) ; # Decode the message from JSON. $ message = base64_decode ( json_decode ( $ message , true ) ) ; if ( \ Sodium \ crypto_auth_verify ( Helpers :: hex2bin ( $ message [ 'mac' ] ) , $ message [ 'msg' ] , $ key ) ) { \ Sodium \ memzero ( $ key ) ; return $ message [ 'msg' ] ; } else { \ Sodium \ memzero ( $ key ) ; throw new Exceptions \ SignatureException ( 'Signature for message invalid.' ) ; } }
Validates a message signature and returns the signed message.

@param string $message The signed message JSON string.
@param string $key The signing key used with the message.
@param string $hashKey The key to hash the key with.
@return string A string returning the output of the signed message.
@throws Exceptions\InvalidTypeException
@throws Exceptions\SignatureException
Validates a message signature and returns the signed message .