Generating x_fp_hash using Python

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
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk