Exemplo n.º 1
0
def main():
    k0, k1 = gen(10, '1010')
    # print k0
    # print k1

    e0 = eval('0', k0, '1011', 10)
    e1 = eval('1', k1, '1011', 10)

    print e0
    print e1
Exemplo n.º 2
0
def adduser():
    user=request.get_json()
    un=user['username']
    pw=user['password']
    mail=user['email']
    ky= keygen.gen()
    new_user = {"username": un, "password": pw, "email": mail, "key":ky} 
    user_id = accounts.insert_one(new_user).inserted_id
    default_game = {"username": un, "id": 1, "grid":[' ',' ',' ',' ',' ',' ',' ',' ',' '], "start_date": time.time(),"winner": " "} 
    new_game = db.current.insert_one(default_game).inserted_id
    sendmail.send(mail,un,ky)
    return jsonify({"username": un, "password": pw, "email": mail, "key":ky,"status":"OK"})
Exemplo n.º 3
0
def adduser():
    req=request.get_json()
    e= req['email']

    if db.accounts.find({"email":e}).count() > 0:
        #unique email
        return jsonify({'status': 'error', 'error':'Email Address already in use'})
    u= req['username']
    if db.accounts.find({"username":u}).count() > 0 :
        #unique username
        return jsonify({'status': 'error', 'error':'Username already in use'}) 
    p= req['password']
    k= keygen.gen()
    sendmail.send(e,u,k)
    new= {"username":u,"password":p, "email":e, "key":k}
    db.accounts.insert_one(new)
    return jsonify({'status': 'OK'})
Exemplo n.º 4
0
            print(encryptedmsg)
            password_dec = keysharing.dec(name + "PrivateKey.pem", b"hi",
                                          encryptedmsg['password'])
            iv_dec = encryptedmsg['iv']
            decryptedmsg = aes.dec(encryptedmsg['encmsg'], password_dec,
                                   iv_dec)
            print("________________________")
            print("incoming msg = ", decryptedmsg)
            print("symmetric password = "******"________________________")
            con = input("to go back to the main menue hit 'b'")
            if (con == 'b'):
                continue

        else:
            print("cant find the msg")
    # generating new key pair
    if (o == '3'):
        d = input("are you sure you want new key pair?<y>/<n>\n")

        if (d == 'y'):
            print("generating new key pair...")
            keygen.gen(name)
            qrimgg = input(
                "new keys generated successfuly, generate QR image?<y>/<n>")
            if (qrimgg == 'y'):
                with open("./outbox/" + name + "PublicKey.pem", "r") as f:
                    mypubkey = f.read()
                qr.gen(mypubkey, name + "publickey", "./outbox/")
    if (o == 'q'):
        break
Exemplo n.º 5
0
    def build_function(self):

        return gen(constant.SEC_PARAM, self.dna_bitstring)