Skip to content

Commit 9c1c37d

Browse files
authored
Merge pull request #50 from KarthikeyanKumar/master
Create compute-transhash-sha512
2 parents e6e33ba + f55e462 commit 9c1c37d

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

sha512/compute-transhash-sha512

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This is a program to compute TransHash for a given Transaction
2+
# Neccessary paramters :- SignatureKey,ApiLoginId, TransId for the Transaction,Amount Transacted
3+
# For more details regarding implementation please visit For more details please visit https://developer.authorize.net/support/hash_upgrade/?utm_campaign=19Q2%20MD5%20Hash%20EOL%20Partner&utm_medium=email&utm_source=Eloqua for implementation details.
4+
5+
6+
import hashlib
7+
import hmac
8+
9+
#SignatureKey is obtained from MINT interface
10+
signatureKey="14B9609FFE2378449B3C0886046DD3B0F20DF12DEB758E48B5FFE1B5875615F0D2A50F7DDB1EAC417EBF76A1FAC374079793650AA493CE127601CB0960938E82";
11+
transId="60115446835";
12+
apiLogin = "5T9cRn9FK";
13+
amount = "10.00";
14+
textToHash="^"+apiLogin+"^"+transId+"^"+amount+"^";
15+
16+
17+
def calculate_TransHashSha512(signatureKey,textToHash):
18+
if(not signatureKey or signatureKey ==''):
19+
raise Exception('Signature key cannot be null or empty')
20+
if(not textToHash or textToHash ==''):
21+
raise Exception('Signature key cannot be null or empty')
22+
if(len(signatureKey)%2!=0 or len(signatureKey)<2):
23+
raise Exception("Parameter cannot be odd or less than 2 characters");
24+
sign=hmac.new(signatureKey.decode("hex"), textToHash, hashlib.sha512).hexdigest().upper()
25+
return sign
26+
27+
transHashSha512=calculate_TransHashSha512(signatureKey,textToHash)
28+
print(transHashSha512)
29+

0 commit comments

Comments
 (0)