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

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

        # Generate a MAC for the message.
        $mac = \Sodium\crypto_auth($message, $key);

        return base64_encode(json_encode([
            'mac' => Helpers::bin2hex($mac),
            'msg' => $message,
        ]));
    }