Example #1
0
def put(msg, pin, exp):
    logger.debug("Start encryption")
    encrypted_msg = libencryption.encrypt(msg)
    logger.debug("Finished encryption: " + encrypted_msg)
    logger.debug("Start app to put data into the database")
    sid = lib.put_secret(encrypted_msg, pin, exp)
    return jsonify(sid=sid)
Example #2
0
def post_secret():
    logger.debug("Invoke: put from a post")
    result = request.json
    msg = result["msg"]
    pin = result["pin"]
    exp = result["exp"]
    encrypted_msg = libencryption.encrypt(msg)
    sid = dblib.put_secret(encrypted_msg, pin, exp)
    return jsonify(sid=sid)
Example #3
0
def add_secret():
    logger.debug("Invoke: put from a post")
    if request.json is None \
            or request.json is not None \
            and ("msg" not in request.json.keys() or "pin" not in request.json.keys() or "exp" not in request.json.keys()):
        logger.debug("Such sid and/or pin does not exist")
        return jsonify({
            'status': "404: request",
            'message': 'Invalid Body url: ' + request.url,
        })
    else:
        result = request.json
        msg = result["msg"]
        pin = result["pin"]
        exp = result["exp"]
    encrypted_msg = libencryption.encrypt(msg)
    sid = dblib.put_secret(encrypted_msg, pin, exp)
    logger.debug("put from a post return sid=" + sid)
    # return jsonify(sid=sid)
    if len(str(sid)) > 0:
        return jsonify(sid=sid)
    else:
        return jsonify(sid=sid, Data="Data is not received from DB")
Example #4
0
def put(msg, pin, exp):
    encrypted_msg = libencryption.encrypt(msg)
    logger.debug("Invoke: put a get")
    sid = dblib.put_secret(encrypted_msg, pin, exp)
    logger.debug("Obtain sid: " + sid)
    return jsonify(sid=sid)
Example #5
0
import libencryption


message = b'encrypt me!'

encrypted_msg = libencryption.encrypt(message)

print(encrypted_msg)
    
decrypted_msg = libencryption.decrypt(encrypted_msg)

print(decrypted_msg)