Skip to content

Commit

Permalink
Non-ascii symbols in key checks added
Browse files Browse the repository at this point in the history
  • Loading branch information
Badiboy committed Jul 25, 2023
1 parent ee52fc5 commit db7b162
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pyCryptomusAPI/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,13 @@ def __request(self, method_url, mode, **kwargs):
base_resp = None
try:
key = self.payment_api_key if (mode == 1) else self.payout_api_key
if key and not(key.isascii()):
raise pyCryptomusAPIException(-6, "Key contains non-ascii characters")
json_dumps = json.dumps(data)
# json_dumps = json.dumps(data, ensure_ascii=False, separators=(',', ':'))
pre_sign = json_dumps if data else ""
if pre_sign and not(pre_sign.isascii()):
raise pyCryptomusAPIException(-6, "Data dump contains non-ascii characters")
sign = md5(base64.b64encode(pre_sign.encode('ascii')) + key.encode('ascii')).hexdigest()
# sign = md5(base64.encodebytes(pre_sign.encode('utf-8')) + key.encode('utf-8')).hexdigest()
headers = {
Expand Down Expand Up @@ -106,6 +110,7 @@ def __request(self, method_url, mode, **kwargs):
if self.print_errors:
print("Response: {}".format(resp))
raise pyCryptomusAPIException(code, message)
# code -6 is used above
else:
return resp

Expand Down

0 comments on commit db7b162

Please sign in to comment.