Skip to main content

HMAC Validation

Upon receiving the HMAC from Zamplia, you can validate it to ensure the message's authenticity and integrity.

  • Validation Example (Python):

    Example (crypto.py)
        import hmac

    import hashlib

    def generate_hmac(key, message):

    return hmac.new(key.encode('utf-8'), message.encode('utf-8'), hashlib.sha256).hexdigest()

    def validate_hmac(key, message, received_hmac):

    calculated_hmac = generate_hmac(key, message)

    return hmac.compare_digest(calculated_hmac, received_hmac)

    secretKey = 'your_secret_key'

    message = 'https://www.example.com/zamplia/security-terminate?uid=Testtermpass555'

    received_hmac = '37f1b56991f5818c730b16e17a3f70907cff569a2dd717909c122eefdbf7a9b1'

    is_valid = validate_hmac(secretKey, message, received_hmac)

    print(f"Is valid: {is_valid}")
    Output:
        Is valid: True