예제 #1
0
def send_message():
    ###function to send secret message
    friend_choice = friends[select_friend()].name

    original_image = raw_input("What is the name of the image?")
    output_path = 'output.jpg'
    ##giving the new name to the encided image
    text = raw_input("What do you want to say?")
    if text in special_words:
        text = colored(text + ": IT'S EMMERGENCY!! Come for help", "red")

    Steganography.encode(original_image, output_path, text)
    ##encoding process
    new_chat = ChatMessage(spy_name=spy_1.name,
                           friend_name=friend_choice,
                           time=datetime.now().strftime("%d %B %Y"),
                           message=text)
    ##storing date and time of function

    chats.append(new_chat)
    ####appending the chat to the friends list

    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
        ])
예제 #2
0
def send_message():

        friend_select = select_friend()
        if friend_select is not False:
            input_path = raw_input("Enter the full path of the image : ")
            output_path = raw_input("Enter path where you want to store the output image : ")
            text = raw_input("Enter secret text that you want to encode : ")

            if name_valid(text) is True:
                if len(text.split()) > 100 :
                    print "You're speaking a lot, this is Intolerable!!\nYou're banished from the chat!! "
                    del friends[friend_select]
                elif len(text.split()) == 0 :
                    print "*****DON'T WASTE TIME OF YOUR FRIEND SPY !"
                else:
                    Steganography.encode(input_path , output_path , text)

                    # VARIABLE TO STORE THE DETAILS OF THE NEW CHAT DATA

                    new_chat = ChatMessage(text,True,0)
                    friends[friend_select].chats.append(new_chat)

                    if text == "SOS" or text == "SAVE ME" or text == "Vatican Cameos" or text == "HELP ME" :
                        print " *****THE MESSAGE IS FORWARDED TO ALL THE SPY'S ! THE NEAREST ONE WILL CONTACT YOU , SIT TIGHT !***** "

                    print("Your secret image is ready !")


            else:
                print " You haven't entered any secret message. Please try again!"
예제 #3
0
def read_message(
):  # this function is defined to read a message sent by a friend

    dict_special_words = {
        'asap': 'as soon as possible',
        'lol': 'laugh out loud',
        'gtg': 'got to go'
    }

    sender = select_a_friend()

    output_path = raw_input("What is the name of the file?")

    secret_text = Steganography.decode(output_path)

    new_chat = ChatMessage(secret_text, False)

    if len(secret_text.split()
           ) > 50:  # Checking if the friend spoke more than 50 word
        friends.remove(friends[sender]
                       )  # Deleting the friend if he spoke more than 50 words
    elif len(secret_text
             ) == 0:  # Checking if the image contains any text or not
        print('there is no secret text in your image')
    else:
        for word in dict_special_words.keys():  # Checking special words
            found = secret_text.find(
                word
            )  # Checking if the the Secret_text contains special words or not
            if found != -1:
                print(word + '=' + dict_special_words[word])

        friends[sender].chats.append(new_chat)
        print secret_text
        print "Your secret message has been saved!"
def send_message_help():
    # select friend who had sent an emergency message.
    friends_choice = select_friend()

    # send the helping text message to the friend in emergency.
    text = "Hey, i am there to help you. "

    # the message will be added to chat message class
    new_chat = ChatMessage(text, True)
예제 #5
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
예제 #6
0
def send_message():  # this function is defined to send a message to a friend

    friend_choice = select_a_friend()

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

    new_chat = ChatMessage(text, True)

    friends[friend_choice].chats.append(new_chat)

    print "Your secret message image is ready!"
예제 #7
0
def read_message():


        sender = select_friend()
        if sender is not False:
            words_spoken = None
            orig_image = raw_input("Enter the full path of the image to be decoded: ")
            secret_text = Steganography.decode(orig_image)
            # No. of words (from message) send by SPY
            for word in friends[sender].chats:
                words_spoken = word.avg_words + len(secret_text.split())

            new_chat = ChatMessage(secret_text,False,words_spoken)
            friends[sender].chats.append(new_chat)
            print secret_text
            print"Your secret message has been decoded and saved!"
예제 #8
0
def readchat(choice):
    name_friend = friends[choice].name
    with open('Chats.csv', 'rU') as chats_data:
        reader = csv.reader(chats_data)
        for row in reader:
            try:
                c = ChatMessage(spy_name=row[0],
                                friend_name=row[1],
                                time=row[2],
                                message=row[3])
                # checking the chats of the current spy with selected friend
                if c.spy_name == spy_1.name and c.friend_name == name_friend:
                    print colored(
                        "You sent message to the Spy name: %s " % name_friend,
                        "red")
                    print colored("On Time: [%s]" % c.time, "blue")
                    print("Message: %s" % c.message)
                    return 1
            except IndexError:
                pass
            continue
예제 #9
0
def read_message():
    ##function to read secret message
    sender = select_friend()

    output_path = raw_input("What is the name of the file?")
    secret_text = Steganography.decode(output_path)
    ##decoding process
    print(secret_text)

    chat = ChatMessage(spy_name=spy_1.name,
                       friend_name=sender,
                       time=datetime.now().strftime("%d %B %Y"),
                       message=secret_text)

    friends[sender].chats.append(chat)
    ###appending the chat
    print "Your secret message has been saved!"

    with open("chats.csv", 'a') as chat_record:
        writer = csv.writer(chat_record)
        writer.writerow(
            [chat.spy_name, chat.friend_name, chat.time, chat.message])