def end(): global seanse global key global Rb msg = request.json['one'] buf = diffie.decrypt(key, msg.encode('utf-8')) seanse = buf[0:16] text = diffie.decrypt(seanse.encode('utf-8'), request.json['two']) #if text[0:16] == Rb return 0
def response(): global key enc = request.json['msg'].encode('utf-8') msg = diffie.decrypt(key, enc) new_message = Message(text=msg, user='******', time=datetime.now()) db.session.add(new_message) db.session.commit() return jsonify({"status": "ok"})
def response(): global key enc = request.json['msg'].encode('utf-8') msg = diffie.decrypt(key, enc) new_message = Message(text = msg, user = '******', time = datetime.now()) db.session.add(new_message) db.session.commit() return jsonify({"status": "ok"}) #curl -X POST -d '{"p":23, "g":5, "A":11}' -H "Content-Type: application/json" http://server-two
def end(): global Ra global seanse global key msg = request.json['one'] buf = diffie.decrypt(key, msg.encode('utf-8')) if buf[16:32] == Ra: seanse = buf[0:16] text = diffie.encrypt(seanse.encode('utf-8'), buf[32:]).decode('utf-8') msg = request.json['two'] requests.post('http://server-bob/end', headers={'Content-Type': 'application/json'}, data=json.dumps({ "one": msg, "two": text })) return 0
def yahalom(): global seanse global key_alice global key_bob global alice global bob bob = request.json['id'] enc = request.json['enc'] #seanse = diffie.gen() seanse = 'SSSSSSSSSSSSSSSS' buf = diffie.decrypt(key_bob, enc.encode('utf-8')) alice = buf[0:16] RaRb = buf[16:] buf = seanse + RaRb enc = diffie.encrypt(key_alice, buf).decode('utf-8') buf = seanse + alice text = diffie.encrypt(key_bob, buf).decode('utf-8') requests.post('http://server-alice/end', headers={'Content-Type': 'application/json'}, data=json.dumps({ "one": enc, "two": text })) return 0