fork download
  1. def new_login(bot, request):
  2. data = request.get_json()
  3. sha256_hash = data['hash']
  4. del data['hash']
  5. data = collections.OrderedDict(sorted(data.items()))
  6. check_string = ''
  7. for key, value in data.items():
  8. check_string += '%s=%s\n' % (key, str(value))
  9. check_string = check_string[:-1]
  10. secret = hashlib.sha256('xxxxxxxxxxx'.encode('utf-8'))
  11. secret = bytes(secret.hexdigest(), 'utf-8')
  12. message = bytes(check_string ,'utf-8')
  13. check_hash = hmac_sha256(secret, message)
  14. print('Получили: ', check_hash)
  15. print('Должно быть: ', sha256_hash)
  16. if check_hash == sha256_hash:
  17. return 'Success', 200
  18. else:
  19. return 'Error', 403
Success #stdin #stdout 0.02s 28384KB
stdin
Standard input is empty
stdout
Standard output is empty