예제 #1
0
def get_messages(id):

    temp_keys = the_keys()

    if str(id) in temp_keys:
        messages = the_message(str(id))
        return render_template('messages-col.html', user=temp_keys[str(id)], messages=messages)
예제 #2
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")
예제 #3
0
def save_new_message(message, n, e):

    temp_keys = the_keys()

    for temp_element in temp_keys:
        print("\n\n\n")
        print(temp_keys[temp_element]["n"] == n
              and temp_keys[temp_element]["e"] == e)
        if temp_keys[temp_element]["n"] == n and temp_keys[temp_element][
                "e"] == e and "d" not in temp_keys[temp_element]:

            temp_message = the_message(temp_element)

            number = str(len(temp_message) + 1)

            temp_message[number] = message

            save_message(temp_message, temp_element)

            return (number)