S
S
Stepan2018-03-12 22:55:11
Django
Stepan, 2018-03-12 22:55:11

How to do hashing in django?

The mango-office documentation has a line to calculate the variable

Значение sign рассчитывается следующим образом:
sign = sha256(vpbx_api_key + json + vpbx_api_salt)

I have all the necessary data and I'm trying to get a hash, but I don't understand how to add them at all
vpbx_api_key = 'xxxxxxxxxx'
vpbx_api_salt = 'nnnnnnnnnnn'
json = {
  "command_id" : "cbk1",
  "from" : {
    "extension" : "1234",
    "number" : "78005553535",
},
  "to_number" : "78005553535",
  "line_number" : "78005553535",
}
sign = hmac.new(bytearray(vpbx_api_key,'utf-8'), bytearray(vpbx_api_salt,'utf-8'), hashlib.sha256).hexdigest()

which way to look next?
update:
vpbx_api_key = 'xxxxxxxxxx'
vpbx_api_salt = 'nnnnnnnnnnn'
data = {
  "command_id" : "cbk1",
  "from" : {
    "extension" : "1234",
    "number" : "78005553535",
},
  "to_number" : "78005553535",
  "line_number" : "78005553535",
}
json_data = json.dumps(data)
sha256sign.update((vpbx_api_key + json_data + vpbx_api_salt).encode('utf-8'))
sign = sha256sign.hexdigest()

I get the same result:
{"name":"Unauthorized","message":"You are requesting with an invalid credential.","code":0,"status":401}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2018-03-13
@ykppon

decompose or support load

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question