Esempio n. 1
0
def send_a_message():
    friend_choice = friends[select_a_friend()].name

    original_image = raw_input("What is the name of the image?")
    output_path = 'output.jpg'
    text = raw_input("What do you want to say?")
    if text in special_words:
        text = colored(text + ": IT'S EMMERGENCY!!", "red")
    #encoding the message
    Steganography.encode(original_image, output_path, text)

    # the message will be stored in chat message class
    new_chat = ChatMessage(spy_name=spy_1.name,
                           friend_name=friend_choice,
                           time=datetime.now().strftime("%d %B %Y"),
                           message=text)

    # name of the friend along which we add message.
    chats.append(new_chat)
    print("your secret message is ready.")

    with open('chats.csv', 'a') as chats_data:
        writer = csv.writer(chats_data)
        writer.writerow([
            new_chat.spy_name, new_chat.friend_name, new_chat.time,
            new_chat.message
        ])
Esempio n. 2
0
def load_chats():
    with open('chats.csv', 'rb') as chats_data:
        reader = csv.reader(chats_data)

        for row in reader:
            cm = ChatMessage(row[0], row[1])
            chats.append(cm)
Esempio n. 3
0
def read_a_message(spy):
    show_menu = True
    while show_menu:
        print colored("which friend you want to communicate with?", "yellow")
        # checks if user has a friend or not
        index = select_a_friend(spy)
        if index < 0:
            show_menu = False
        else:
            sender = friends[index].name
            # sender stores index of friend whose message user want to read
            output_path = raw_input(colored("enter the name of the image you want to decode(.jpg format) : ", "yellow"))
            # checking if mentioned file exist in os or not
            if os.path.exists(output_path):
                # checking extension of image if its in jpg
                if os.path.splitext(output_path)[1] == ".jpg":
                    text = Steganography.decode(output_path)
                    # decode method of Steganography library will retrieve hidden secrete message in selected image
                    print colored("your received text: " + text , "blue")
                    if text in special_text:
                        print colored("don't worry " + sender + "on the way to rescue you!!!", "green", attrs=['bold'])
                    # storing chats in chatmessage
                    chat = ChatMessage(sent_by_me=spy.name, friend_name=sender, time=datetime.now().strftime("%d %B %Y"), message=text)
                    chats.append(chat)
                    # writing chats in chats.csv
                    with open("chats.csv", 'a') as chat_record:
                        writer = csv.writer(chat_record)
                        writer.writerow([chat.sent_by_me, chat.friend_name, chat.time, chat.message])
                    show_menu = False
                else:
                    print colored("file not in .jpg format", "red")
            else:
                print colored("file does not exist", "red")
Esempio n. 4
0
def send_a_message(spy):
    show_menu = True
    while show_menu:
        print colored("which friend you want to communicate with?", "yellow")
        index = select_a_friend(spy)
        # checks if user has a friend or not
        if index < 0:
            show_menu = False
        else:
            selected_friend = friends[index].name
            # selected_friend contains index of friend selected via select_a_friend function
            original_image = raw_input(colored("enter name of image you want to encode secret message with(.jpg format): ", "yellow"))
            # checking if mentioned file exist in os or not
            if os.path.exists(original_image):
                # checking extension of image if its in jpg
                if os.path.splitext(original_image)[1] == ".jpg":
                    output_path = 'output.jpg'
                    text = raw_input(colored("enter secret message you want to hide: ", "yellow"))
                    if text in special_text:
                        text = colored(text + ": its a emergency reach me as soon as possible!!", "red", attrs=['bold'])
                    # encode method of Steganography library will hide secrete message in selected image
                    Steganography.encode(original_image, output_path, text)
                    # storing chats in chatmessage
                    chat = ChatMessage(sent_by_me=spy.name, friend_name=selected_friend, time=datetime.now().strftime("%d %B %Y"), message=text)
                    chats.append(chat)
                    # writing chats in chats.csv
                    with open("chats.csv", 'a') as chat_record:
                        writer = csv.writer(chat_record)
                        writer.writerow([chat.sent_by_me, chat.friend_name, chat.time, chat.message])
                    print colored("your secret message is sent", "blue")
                    show_menu = False
                else:
                    print colored("file not in .jpg format", "red")
            else:
                print colored("file does not exist", "red")
Esempio n. 5
0
def send_message():
    friend_choice = friends[select_a_friend()].name

    original_image = raw_input("What is the name of the image?")
    #output.jpg is a output image, with output name
    output_path = 'output.jpg'
    text = raw_input("What do you want to say?")

    # encoding the message
    Steganography.encode(original_image, output_path, text)

    # the message will be stored in chat
    new_chat = ChatMessage(spy_name=spy_1.name,
                           friend_name=friend_choice,
                           time=datetime.now().strftime("%d %B %Y"),
                           message=text)
    #append new_chat in chats list.
    chats.append(new_chat)
    print("your secret message is ready.")

    with open('chats.csv', 'a') as chats_data:
        writer = csv.writer(chats_data)
        writer.writerow([
            new_chat.spy_name, new_chat.friend_name, new_chat.time,
            new_chat.message
        ])
Esempio n. 6
0
def load_chats():
    with open('chats.csv', 'rU') as chats_data:
        reader = csv.reader(chats_data,delimiter=',', quotechar='"')

        for row in reader:
            chat = ChatMessage(row[0], row[1])
            chats.append(spy)
Esempio n. 7
0
 def load_chats():
     with open("chats.csv", 'rU') as chat_data:
         reader = csv.reader(chat_data)
         for row in reader:
             try:
                 chats.append(ChatMessage(spy_name=row[0], friend_name=row[1], time=row[2], message=row[3]))
             except IndexError:
                 pass
             continue
Esempio n. 8
0
def send_message():
    #Choosing friend
    friend_choice = select_a_friend()
    #secret message in an image
    original_image = raw_input(
        "What is the name of the image?(Specify the path):")
    output_path = "output.jpg"
    text = raw_input("What do you want to say? ")
    Steganography.encode(original_image, output_path, text)
    new_chat = ChatMessage(friend_choice, text, True)
    #writing to a csv file
    with open('chat.csv', 'a') as chat_data:
        writer = csv.writer(chat_data)
        writer.writerow([new_chat.message])

    chats.append(new_chat)

    print "Your secret message image is ready!"
Esempio n. 9
0
def read_message():
    #Selecting a sender
    sender = select_a_friend()
    special_word = ["SOS", "Save me", "Help", "Bachao", "N***a", "Dead"]
    output_path = raw_input("What is the name of the file?(specify the path):")

    #decoding
    secret_text = Steganography.decode(output_path)
    if secret_text in special_word:
        print "Wait for 5 minutes I'll come in 10"

    new_chat = ChatMessage(sender, secret_text, False)
    #writing to a csv
    with open('chats.csv', 'a') as chat_data:
        writer = csv.writer(chat_data)
        writer.writerow([new_chat.message])

    chats.append(new_chat)
    print "Your secret message has been saved!"