Generating x_fp_hash using Python

Created by Richard Moore, Modified on Wed, 12 Apr 2023 at 12:02 PM by Richard Moore

To generate x_fp_hash using Python please see the code below:


import hmac
import hashlib

# Instantiate hmac with Transaction key (HMAC-MD5)
# digest_maker = hmac.new('V0WX5fK~o6eEhr7hbs3ZeyxS', '', hashlib.md5)

# Instantiate hmac with Transaction key (HMAC-SHA1)
digest_maker = hmac.new('V0WX5fK~o6eEhr7hbs3ZeyxS', '', hashlib.sha1)

format = '%(x_login)s^%(x_fp_sequence)s^%(x_fp_timestamp)s^%(x_amount)s^%(x_currency)s'
data =  format % {'x_login' : 'WSP-ACTIV-70',
                  'x_fp_sequence' : '123',
                  'x_fp_timestamp' : '1228774539',
                  'x_amount' : '100.00',
                  'x_currency' : ''}

digest_maker.update(data)
x_fp_hash = digest_maker.hexdigest()
print x_fp_hash

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article