コード例 #1
0
    def test_create_and_saving_and_deleting(self):

        name = "onur"
        fromUser = "******"

        n = 111
        e = 111

        temp_user = create_new_user(name, fromUser, n, e)

        message = {"from": "me", "message": "hello"}

        number = save_new_message(message, n, e)

        #save_new_message({"from":"sender","message":"hello how are you"},n,e)

        ok = False

        temp_message_object = the_message(temp_user)

        if number in temp_message_object:
            if temp_message_object[number] == message:
                ok = True

        key_delete(temp_user)

        message_delete(temp_user)

        self.assertEqual(ok, True, "A problem on the test_encrypt_decrypt")
コード例 #2
0
def add_new_user_request(publickey):
    key = the_keys()["1"]

    data = {
        "app": "messagingapp",
        "command": "addnewuser",
        "n": key["n"],
        "e": key["e"]
    }
    send(Wallet_Import(0, 0),
         Wallet_Import(0, 1),
         publickey,
         data=data,
         amount=0)

    create_new_user("unknow", publickey, 0, 0)
コード例 #3
0
    def test_create_and_saving_and_deleting(self):
   
        

        name = "onur"

        pubkey = "onurspubkey"

        n = 111
        e = 111


        temp_user = create_new_user(name,pubkey,n,e)

        temp_user_object = the_keys()[temp_user]

        
        ok = False
        if temp_user_object["name"] == name and temp_user_object["n"] == n and temp_user_object["e"] == e:
            ok = True


        key_delete(temp_user)



        self.assertEqual(ok,True,"A problem on the test_encrypt_decrypt")
コード例 #4
0
def messaging_app_main_tx(tx):
    tx_pubkey = tx.toUser
    tx_pubkey_fromUser = tx.fromUser
    my_pubkey = "".join([
        l.strip() for l in Wallet_Import(0, 0).splitlines()
        if l and not l.startswith("-----")
    ])

    print("\n")
    print("\n\n" + tx_pubkey)
    print(my_pubkey + "\n\n")
    print(tx_pubkey == my_pubkey or tx_pubkey in my_pubkey
          or my_pubkey in tx_pubkey)
    print(tx.__dict__)
    print(tx.data)
    print(type(tx.data))
    print("\n")

    control = False
    to_User = False
    from_User = False
    if tx_pubkey == my_pubkey or tx_pubkey in my_pubkey or my_pubkey in tx_pubkey:
        control = True
        to_User = True
    elif tx_pubkey_fromUser == my_pubkey or tx_pubkey_fromUser in my_pubkey or my_pubkey in tx_pubkey_fromUser:
        control = True
        from_User = True

    if control:
        if tx.data != None:
            print("\n not none \n")
            if "app" in tx.data:
                print("\n app in data \n")
                if tx.data["app"] == "messagingapp":
                    print("""\n tx.data["app"] == "messagingapp" \n""")
                    if tx.data["command"] == "addnewuser" and to_User:
                        print("""\n tx.data["command"] == "addnewuser" \n""")
                        from apps.Messaging_App.func.create_new_user import create_new_user
                        create_new_user("unknow", tx.fromUser, tx.data["n"],
                                        tx.data["e"])
                    elif tx.data["command"] == "newmessage" and to_User:
                        from apps.Messaging_App.func.decrypt import decrypt_text
                        decrypt_text(tx.data["message"], tx_pubkey_fromUser)