THE FORUM IS IN READ-ONLY MODE

This forum is in read-only mode. The new forum is live at https://discourse.openbullet.dev and registrations are open!

HMAC-256 Help



  • My Python Code

    import hmac
    import hashlib
    import base64
    
    SUP = base64.b64encode(hashlib.sha256('{"user":"[email protected]","meta":{"event":"login","store":"android","adid":"72196d1d-4027-468b-b920-9611c5daff07","platform":"1.13.2","tracking":"/"}}'.encode("UTF8")).digest())
    print(b"SHA-256+BASE64: "+SUP)
    
    #OUTPUT -> b'SHA-256+BASE64: awxY8392SBkwJmAMKkZ05Jaa8zaeGvsEflfbqnYt1vg='
    
    HMAC_RESP = base64.b64encode(hmac.new(b'25jnMhmRv3m19r7o4Dzv', msg=b"x-date: Thu, 01 Jan 1970 00:01:15 GMT+00:00\ndigest: SHA-256="+SUP, digestmod=hashlib.sha256).digest())
    print(b"HMAC+BASE64: "+HMAC_RESP)
    
    #OUTPUT -> b'HMAC+BASE64: qfPct7Byy2eQIOCP1QR8jmrZ2JnLw56LliZb2SWQx70='
    

    OBS: I need get this output in openbullet -> qfPct7Byy2eQIOCP1QR8jmrZ2JnLw56LliZb2SWQx70=

    My OB Code

    #FUNCTION_SHA256 FUNCTION Hash SHA256 "{\"user\":\"[email protected]\",\"meta\":{\"event\":\"login\",\"store\":\"android\",\"adid\":\"72196d1d-4027-468b-b920-9611c5daff07\",\"platform\":\"1.13.2\",\"tracking\":\"/\"}}" -> VAR "DT" 
    
    #UTILITY_SHAB64 UTILITY Conversion HEX BASE64 "<DT>" -> VAR "RES-SHA" 
    
    #FUNCTION_HMAC FUNCTION HMAC SHA256 "25jnMhmRv3m19r7o4Dzv" HmacBase64=TRUE "x-date: Thu, 01 Jan 1970 00:01:15 GMT+00:00\\ndigest: SHA-256=<RES-SHA>" -> VAR "HMAC" 
    
    

    OUTPUT -> 3YuNpzWbjCQHhO+z20Wf+5I1zS6Ovx2LCyiFygAqUzo=



  • @ManoPlayBRL It won't be the best way but it work ^__^

    #FUNCTION_SUP FUNCTION Hash SHA256 "{\"user\":\"[email protected]\",\"meta\":{\"event\":\"login\",\"store\":\"android\",\"adid\":\"72196d1d-4027-468b-b920-9611c5daff07\",\"platform\":\"1.13.2\",\"tracking\":\"/\"}}" -> VAR "SUP" 
    UTILITY Conversion HEX BASE64 "<SUP>" -> VAR "Result" 
    #UTILITY_Result2 UTILITY Conversion UTF8 BIN "x-date: Thu, 01 Jan 1970 00:01:15 GMT+00:00" -> VAR "Result2" 
    #UTILITY_Result3 UTILITY Conversion UTF8 BIN "digest: SHA-256=" -> VAR "Result3" 
    #UTILITY_Result4 UTILITY Conversion BIN BASE64 "<Result2>00001010<Result3>" -> VAR "Result4" 
    #FUNCTION_msg FUNCTION Base64Encode "<Result>" -> VAR "msg" 
    #FUNCTION_HMAC FUNCTION HMAC SHA256 "25jnMhmRv3m19r7o4Dzv" InputBase64=TRUE HmacBase64=TRUE "<Result4><msg>" -> VAR "FINAL_Result" 
    
    

    HMAC.png



  • @Br4uN You saved my day brother Really thx for your help 🙂 😁 Could you explain to me why he needs to send to binary?



  • @ManoPlayBRL Because you want result in digest I guess, and it was the faster and easy way for me 😁 to replicate your py code. I belive google has a better answer than me 🤦 sorry



  • @Br4uN Alright 😄 Thanks for your help


Log in to reply