[Python] Generate SHA256 HMAC signature in Python

Discussão em 'Python' iniciado por Stack, Abril 10, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to generate a SHA256 HMAC signature for a FTX websocket. I am using the params fromt he official example https://docs.ftx.com/#private-channels.

    It should generate d10b5a67a1a941ae9463a60b285ae845cdeac1b11edc7da9977bef0228b96de9

    but I am getting ad38fa3566de972abb736bc0db2f7cd39daa48b14421e168422303bf2f03c6de

    here is what I tried:

    import hmac
    import hashlib
    import base64

    time = '1557246346499'
    secret = 'Y2QTHI23f23f23jfjas23f23To0RfUwX3H42fvN-'


    digest = hmac.new(bytes(time, 'UTF-8'),
    bytes(secret, 'UTF-8'), hashlib.sha256)
    signature = digest.hexdigest()
    print(signature)

    Continue reading...

Compartilhe esta Página