-
-
Save satiani/fbc1fb05a8373f16c7c0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base64 | |
import urllib | |
import codecs | |
from Crypto.Cipher import AES | |
from Crypto.Hash import MD5 | |
temp_token = "value from propay" | |
temp_token = codecs.encode(temp_token, 'utf-8') | |
settings = { | |
'AuthToken' : temp_token, | |
'PayerId' : propay_payer_id, | |
'PaymentProcessType' : 'CreditCard', | |
'ProcessMethod' : 'None', | |
'PaymentMethodStorageOption' : 'Always', | |
'ReturnURL' : "http://example_url.com/example" | |
} | |
encoded_settings = urllib.urlencode(settings) | |
encoded_settings = codecs.encode(encoded_settings, 'utf-8') | |
md = MD5.new() | |
md.update(temp_token) | |
key = md.digest() | |
iv = key | |
block_size = 16 | |
pad = block_size - (len(encoded_settings) % block_size) | |
encoded_settings = encoded_settings + pad*chr(pad) | |
aes = AES.new(key, IV=iv, mode=AES.MODE_CBC) | |
settings_cipher = base64.b64encode(aes.encrypt(encoded_settings)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment