本文整理汇总了Python中tools.Tools.checkSignature方法的典型用法代码示例。如果您正苦于以下问题:Python Tools.checkSignature方法的具体用法?Python Tools.checkSignature怎么用?Python Tools.checkSignature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tools.Tools
的用法示例。
在下文中一共展示了Tools.checkSignature方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: phone_post_coordinates
# 需要导入模块: from tools import Tools [as 别名]
# 或者: from tools.Tools import checkSignature [as 别名]
def phone_post_coordinates():
if not "id" in request.form:
return jsonify({"error": "id not present"}), 400
if not "signature" in request.form:
return jsonify({"error": "signature not present"}), 400
if not "long" in request.form or not "lat" in request.form:
return jsonify({"error": "position not present"}), 400
r = get_db()
_signature = request.form['signature']
_id = request.form['id']
_long = float(request.form['long'])
_lat = float(request.form['lat'])
obj = Tools.getData(r, "device_" + _id)
if not "secret" in obj:
return jsonify({"error": "secret not present"}), 400
if not Tools.checkSignature(_id, obj["secret"], _signature):
return jsonify({"error": "wrong signature"}), 400
r.lpush("coordinates_" + _id, str(_lat) + ", " + str(_long))
return jsonify({"saved": "true"})
示例2: phone_registered
# 需要导入模块: from tools import Tools [as 别名]
# 或者: from tools.Tools import checkSignature [as 别名]
def phone_registered():
r = get_db()
if not "code" in request.form:
return jsonify({"error": "code not present"}), 400
if not "signature" in request.form:
return jsonify({"error": "signature not present"}), 400
_6digits = request.form['code']
_signature = request.form['signature']
if not r.hexists("waiting_devices", _6digits):
return jsonify({"error": "device not known"}), 404
_id = r.hget("waiting_devices", _6digits)
obj = Tools.getData(r, "device_" + _id)
print("registered: device_" + _id + ", obj: " + str(obj) + ", 6digits" + _6digits + ", signature: " + _signature)
if not "secret" in obj:
return jsonify({"error": "secret not present"}), 404
if not Tools.checkSignature(_id, obj["secret"], _signature):
return jsonify({"error": "wrong signature"}), 400
if not "owner" in obj:
return jsonify({"registered": "false"})
return jsonify({"registered": "true", "owner": obj["owner"]})