Exemplo n.º 1
0
def send_message():

    friend_choice = select_a_friend()

    original_image = raw_input("What is the name of the image?")
    output_path = "steganography.jpg"
    text = raw_input("What do you want to say? ")
    #condition it encode the origina image,text,output path and message shown in image is secret
    Steganography.encode(original_image, output_path, text)

    new_chat = ChatMessage(text, True)

    friends[friend_choice].chats.append(new_chat)

    print colored("Your secret message image is ready!", "blue")
Exemplo n.º 2
0
def send_message(spy_name):
    selection = select_a_friend();
    image = raw_input("Name of image to be encoded :")
    out_path = "abc1.jpg"
    text = raw_input("what text do you want to encode :")
    text = send_message_help(text)
    Steganography.encode(image, out_path, text)
    print("Message sent... ")
    #text = "You : " + text

    chat=ChatMessage(spy_name=spy_name, friend_name=Friends[selection].Name, message=text, time=datetime.now(), sent_by_me=True)
    with open('chats.csv', 'a') as chat_data:
        writer = csv.writer(chat_data)
        writer.writerow([spy_name, Friends[selection].Name, text, datetime.now(), True])
    Friends[selection].chats.append(chat)
Exemplo n.º 3
0
def send_message():

    friend = select_a_friend()

    original_image = raw_input("What is the name of the image?")

    output_path = "C:\Users\com\Desktop\secret\output.jpg"

    text = raw_input("What do you want to say? ")

    new_chat = ChatMessage(text, True)

    Steganography.encode(original_image, output_path, text)

    FRIENDS[friend].chats.append(new_chat)
Exemplo n.º 4
0
def read_message():

    selected_frnd = select_frnd()

    output_path = raw_input("which image you want to decode? ")

    secret_text = Steganography.decode(output_path)

    print "secret text is " + secret_text

    new_chat = ChatMessage(secret_text, False)

    friends[selected_frnd].chats.append(new_chat)

    print "your secret message has been saved"
Exemplo n.º 5
0
def send_message():

    # choosing friend to send a new secret message
    chosen_friend = select_a_friend()

    input_image_path = raw_input(
        "What is the name [with full path] of the image? ")
    output_image_path = "output.jpg"
    hidden_text = raw_input("Type your secret message here: ")

    # checking for hidden text whether spy is in some emergency or not, if so send an immediate alert to the friend
    msg_part1, msg_part2 = check_if_any_sos(hidden_text)

    # If found any sos, sent an immediate emergency alert to thier spy friend
    if msg_part1 != 0 and msg_part2 != 0:
        hidden_text = "Hey! %s " % (spy.name) + msg_part1 + " %s " % (
            friend_list[chosen_friend].name) + msg_part2

    # Encoding the message using steganography
    try:
        Steganography.encode(input_image_path, output_image_path, hidden_text)

    except Exception as e:
        msg = "Error : %s" % (e)
        message_box(msg, "Oops", 0)

    sent_by_me = True
    t = datetime.now()
    time = t.strftime("%d %B %Y %A at %H:%M:%S")
    new_chat = ChatMessage(hidden_text, sent_by_me, time)

    # savaing chat
    friend_list[chosen_friend].chats.append(new_chat)

    # writing chat to the database file chats_database.csv for permanent use
    try:
        with open("chats_database.csv", "a") as chats_data:

            write_object = csv.writer(chats_data, delimiter=',')
            write_object.writerow([
                friend_list[chosen_friend].salutation,
                friend_list[chosen_friend].name, hidden_text, new_chat.time,
                new_chat.sent_by_me
            ])
            print "Your secret message has been sent!"

    except csv.Error as e1:
        sys.exit('file chats_database.csv", error name: %s' % (e1))
Exemplo n.º 6
0
def send_message():
    #Choosing Friends
    friend_choice = select_friend()
    #Using Regex
    original_image = raw_input("Enter the name of image : ")
    pattern_i = '^[a-zA-Z]+\.jpg$'

    if re.match(pattern_i, original_image) != None:
        print " Image Name entered "
    else:
        print " Please Enter a valid Image name"
    output_image = raw_input("Provide the name of the output image  : ")
    pattern_o = '^[a-zA-Z]+\.jpg$'

    if re.match(pattern_o, original_image) != None:
        print " Image Name entered "
    else:
        print " Please Enter a valid Image name"
    text = raw_input("Enter your message here : ")
    #Encoding the Message
    Steganography.encode(original_image, output_image, text)

    new_chat = ChatMessage(text, True)

    friends[friend_choice].chats.append(new_chat)

    print(colored("Your message encrypted successfully.", 'red'))
    #Dictionary
    new_chat = {'message': text, 'time': datetime.now(), 'sent_by_me': True}

    friends[friend_choice].chats.append(new_chat)
    print(colored("your secret message is ready.", 'yellow'))

    # users input validations
    if (re.match(pattern_i, original_image) != None
            and re.match(pattern_o, output_image) != None):
        print(colored('All perfect', 'red'))
    else:
        print(
            colored(
                'Sorry! Invalid entry. We can\'t validate your input and output\n ',
                'blue'))
        print(colored('The convention to follow is: \n ', 'blue'))
        print(colored('1. Input should ends with (.jpg) format.\n ', 'blue'))
        print(
            colored('2. Output should also ends with (.jpg) format.\n ',
                    'blue'))
        print(colored('Keep in mind and Try Again\n\n ', 'blue'))
Exemplo n.º 7
0
def read_message():
    sender = select_a_friend()

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

    hidden_text = Steganography.decode(output_path)

    print hidden_text

    new_chat = ChatMessage(hidden_text, False)

    friends[sender].chats.append(new_chat)
    # new chats r added
    words = hidden_text.split(' ')
    print 'words in the secret message is : ' + str(len(words))
    print 'hidden text has been saved! ;)\n'
Exemplo n.º 8
0
def read_message():
    if len(friends) == 0:  #check if there are friends
        print "No friends and messages!"

    else:
        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)

        friends[sender].chats.append(new_chat)

        print "Your secret message has been saved!"
Exemplo n.º 9
0
def read_message():

    sender = select_a_friend()

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

    secret_text = Steganography.decode(output_path)
    for each in messages:  # special received message handling like help me,save me etc.
        if secret_text == each:
            print "Your friend is in Danger."

    new_chat = ChatMessage(secret_text, False)

    friends[sender].chats.append(new_chat)

    print "Your secret message has been saved!"
Exemplo n.º 10
0
def read_message():
    sender = select_a_friend()
    output_path = raw_input("What is the name of the file to be decoded?")
    secret_text = Steganography.decode(output_path)
    print("your secret message is:" + secret_text)
    print(secret_text)
    new_chat = ChatMessage(message=secret_text, sent_by_me=False)
    friends[sender].chats.append(new_chat)
    print "Your secret message has been saved!"
    with open("chats.csv", 'ab') as chats_data:
        write = csv.writer(chats_data)
        write.writerow([
            friends[sender].name, secret_text, new_chat.time,
            new_chat.sent_by_me
        ])
    print "Your secret message has been saved!"
Exemplo n.º 11
0
def read_a_message():
    sender = select_a_friend()
    output_path = raw_input(colored("What is tha name of output image",
                                    'blue'))
    secret_text = Steganography.decode(output_path)
    print secret_text
    if 0 < len(secret_text) < 100:
        new_chat = ChatMessage(secret_text, True)

        friends[sender].chats.append(new_chat)
    elif len(secret_text) > 100:
        del friends[sender]
    else:
        print "image doesn't have any message"

    print "Your secret message has been saved!"
Exemplo n.º 12
0
def send_message():

    friend_choice= select_friend()


    original_image=raw_input("Enter the name of image in which message has to be hidden :")
    pattern = '^[a-zA-Z]+\.jpg$'
    if (re.match(pattern, original_image) != None):
        output_image = raw_input("Enter the name of output image :")
        text = raw_input("Enter your message")
        Steganography.encode(original_image, output_image, text)
        new_chat = ChatMessage(text, True)
        friends[friend_choice].chats.append(new_chat)
        print 'Your secret message is ready'
    else:
        print "Invalid image name. try .jpg images only."
Exemplo n.º 13
0
def send_message():
    friend_choice = select_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?")
    #encode the message in image form
    Steganography.encode(original_image, output_path, text)
    ch = ChatMessage(text, True)
    (friend_choice.chats).append(ch)
    if text == "SAVE ME" or text == "SOS":
        print "I am in danger. Please help me out ASAP"
    print "Your secret message is ready"
    # save the chats to chats.csv file
    with open('chats.csv', 'ab') as chats_data:
        writer = csv.writer(chats_data)
        writer.writerow([ch.message, ch.time])
Exemplo n.º 14
0
def send_message():
    #Choose a friend to send a message to
    friend_choice = select_a_friend()
    #Name Of the Image Used For Stegnography
    original_image = raw_input("What is the name of the image?")
    output_path = "output.jpg"  #OutPut Image Path and Name
    text = raw_input(
        "What do you want to say? ")  #Message to be hidden in the image
    Steganography.encode(original_image, output_path,
                         text)  #Steganography Funcion Call to get output image
    #Assigning the variable new_chat
    new_chat = ChatMessage(text, True)
    #Append the Value of new_chat to the chosen friend's chat List
    friends[friend_choice].chats.append(new_chat)

    print "Your secret message image is ready!"
Exemplo n.º 15
0
def read_message(sname):
    sender = select_friend(sname)
    message = ''
    n = input('Enter the Number of images')
    try:
        for x in range(n):
            output_path = raw_input("What is the name of the file?")
            secret_text = Steganography.decode(
                output_path)  # decoding text hidden in image
            message += secret_text + ' '
        chat_obj = ChatMessage(message, False)
        friends[sender].chats.append(chat_obj)
        print colored("Your message is saved!", 'blue', attrs=['blink'])
    except Exception as e:
        print e
        print 'exception in decoding message'
Exemplo n.º 16
0
def send_a_message():
    #choose from the list of spy friends added by the user
    friend_choice = select_a_friend()
    print friend_choice
    #name of the image user want to encode the secret message with
    original_image = raw_input("What is the name of the image?")
    original_image = "secret\%s" % (original_image)
    output_path = raw_input("Save image as")
    #secret message want to hide
    output_path = "secret\%s" % (output_path)
    text = raw_input("What do you want to say? ")
    Steganography.encode(original_image, output_path, text)
    new_chat = ChatMessage(text, True)
    #Append the chat message to 'chats' key for the friends list
    FRIENDS[friend_choice].chats.append(new_chat)
    print "Your secret message image is ready!"
Exemplo n.º 17
0
def send_message():
    # now we have to encypt the text in image which is also called steanography

    friend_choice = select_a_friend()

    original_image = raw_input("What is the name of the image?")
    output_path = "decod.jpg"
    text = raw_input("What do you want to say? ")
    Steganography.encode(original_image, output_path,
                         text)  #here we are encrypting the msg the text

    new_chat = ChatMessage(text, True)

    friends[friend_choice].chats.append(new_chat)

    print "Your secret message image is ready!"
Exemplo n.º 18
0
def read_message():

   #get the position of the friend whose chat we need to read, using the select_friend() function.
   sender = select_friend()

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

   #The decode fucntion takes the image with the hidden secret message as input and returns the secret text.
   secret_text = Steganography.decode(output_path)
   #To save the secret message that we decoded in the read_message() function along with the current timestamp.
   new_chat = ChatMessage(secret_text,False)

   friends[sender].chats.append(new_chat)

   print "Your secret message has been saved!"
   print  secret_text
Exemplo n.º 19
0
def send_a_secretMessage() :
    select = select_a_Friend()
    receiver = select
    #org_Img = raw_input("Please enter the name of the image:  ")
    org_Img = "C:\Users\Lakshay Rajput\PycharmProjects\untitled\\z.jpg"
    new_Img = raw_input("New name of the image: ")
    new_Img = "C:\Users\Lakshay Rajput\PycharmProjects\untitled\\" +new_Img+".jpg"
    text = raw_input("Enter the message you wanna send to your friend: ")
    while len(text) <=0  :
        text = raw_input("You didn't send any message.PLzz enter again: ")

    Steganography.encode(org_Img,new_Img,text)
    chat = ChatMessage(text, True)
    friends[select].chats.append(chat)

    print (friends[select].chats[0].message)
Exemplo n.º 20
0
def read_message(spy):
    try:
        friend_choice = select_friend()
        output_path = raw_input('Enter image path ')
        try:
            secret_text = Steganography.decode(output_path)
            new_chat = ChatMessage(spy_id=friends[friend_choice].id, friend_id=spy.id, message=secret_text,time= datetime.now().strftime("%b %d %Y %H:%M"))
            new_chat.save()

            friends[friend_choice].chats.append(new_chat)
            print "Your secret message is ready!"
        except IOError:
            print 'File Not Found'

    except:
        print 'Operation Unsuccessful'
Exemplo n.º 21
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
Exemplo n.º 22
0
def send_message():
	friend_choice = select_a_friend()
	#path for file to encode(input from user) 
	original_image = raw_input("give a name of file to which you\'ve to encode message :\n")
	original_image += '.jpg'
	#path for file which will store message
	output_path = raw_input("\nfile name for encoded file  : ")
	output_path += '.jpg'
	text = raw_input("What do you want to say? ")
	#encoding image
	Steganography.encode(original_image, output_path, text)
	#new object for ChatMessage class
	new_chat = ChatMessage(text,True)
	#adding chat information to chat list(maintained as object to Spy class )
	friends[friend_choice].chats.append(new_chat)
	print "Your secret message image is ready!"
Exemplo n.º 23
0
def send_message():
    friend_choice = select_a_friend()
    original_image = raw_input("What is the name of the image?")
    output_path = "C:\Users\moham\Desktop\Secret\output.jpg"
    #Validation for not entering message
    while True:
        text = raw_input("What do you want to say? ")
        words = text.split()
        length=sum(len(word) for word in words)
        if text !=("") and length <=100:
            Steganography.encode(original_image, output_path, text)
            break
        prRed("ERROR !!! Either empty or 100 words exceeded")
    new_chat = ChatMessage(text,True)
    friends[friend_choice].chats.append(new_chat)
    print "Your secret message image is ready!"
Exemplo n.º 24
0
def read_message():
    sender = select_friend()
    encrypted_image = raw_input("Provide encrypted image : ")
    pattern_e = '^[a-zA-Z]+\.jpg$'
    if re.match(pattern_e,encrypted_image)!=None:
        print" Image Name entered "
    else:
        print " Please Enter a valid Image name"

#Decrypting the message
    try:
        secret_message = Steganography.decode(encrypted_image)
        print "The secret message is ",
        print (colored(secret_message, 'red'))
        words = secret_message.split()

        new = (secret_message.upper()).split()

#in case of emergency
        if "SOS" in new or "SAVE" in new or "HELP" in new or "ACCIDENT" in new or "ALERT" in new:

            print (colored("!", 'grey', 'on_yellow')),
            print (colored("!", 'grey', 'on_yellow')),
            print (colored("!", 'grey', 'on_yellow'))

            print (colored("The friend who sent this message need your help.", 'cyan'))
            print (colored("You can help your friend by sending helping message.", 'cyan'))
            print (colored("Select the friend to send helping message", 'red'))

        send_message_help()

        print (colored("You just sent a message to help your friend.", 'magenta'))

        new_chat = ChatMessage(secret_message, False)
        friends[sender].chats.append(new_chat)
        print (colored("Your secret message has been saved.", 'cyan'))

    except TypeError:
        print(colored("This image has no secret message. No decoding. Aah!"))

        if (re.match(pattern_e, encrypted_image) != None):
            print (colored('All perfect', 'red'))
        else:
            print (colored('Sorry! Invalid entry. We can\'t validate your input and output\n ', 'blue'))
            print (colored('The convention to follow is: \n ', 'blue'))
            print (colored('1. Encrypted should ends with (.jpg) format.\n ', 'blue'))
            print (colored('Keep in mind and Try Again\n\n ', 'blue'))
Exemplo n.º 25
0
def send_message():

    # choose a friend from the list to communicate
    friend_choice = select_friend()

    # select an image in which you want to hide a secret message.
    original_image = raw_input("Provide the name of the image to hide the message : ")
    pattern_i = '^[a-zA-Z]+\.jpg$'

    # name the output file
    output_image = raw_input("Provide the name of the output image  : ")
    pattern_o = '^[a-zA-Z]+\.jpg$'

    # write the secret message
    text = raw_input("Enter your message here : ")
    # Encrypt the message using Steganography library
    Steganography.encode(original_image, output_image, text)

    # the message will be stored in chat message class
    new_chat = ChatMessage(text, True)

    # along the name of friend with whom we add message
    friends[friend_choice].chats.append(new_chat)

    # Successful message after encoding
    print (colored("Your message encrypted successfully.", 'red'))

    # save the messages
    new_chat = {
        'message': text,
        'time': datetime.now(),
        'sent_by_me': True
    }

    # name of the friend along which we add message.
    friends[friend_choice].chats.append(new_chat)
    print (colored("your secret message is ready.",'yellow'))

    # users input validations
    if (re.match(pattern_i, original_image) != None and re.match(pattern_o, output_image) != None):
        print (colored('All perfect','red'))
    else:
        print (colored('Sorry! Invalid entry. We can\'t validate your input and output\n ', 'blue'))
        print (colored('The convention to follow is: \n ', 'blue'))
        print (colored('1. Input should ends with (.jpg) format.\n ', 'blue'))
        print (colored('2. Output should also ends with (.jpg) format.\n ', 'blue'))
        print (colored('Keep in mind and Try Again\n\n ', 'blue'))
Exemplo n.º 26
0
def read_message():
    sender = select_a_friend(
    )  #  call the select_a_friend method to get which friend is to be communicated with.
    output_path = raw_input(
        "What is the name of the file?"
    )  # Ask the user for the name of the image they want to decode the message from.
    secret_text = Steganography.decode(output_path)
    new_chat = ChatMessage(secret_text, False)
    friends[sender].chats.append(new_chat)
    friends[sender].chats_avg[0] += len(secret_text)
    friends[sender].chats_avg[1] += 1

    words = secret_text.split("_")
    #  Delete a spy from your list of spies if they are speaking too much i.e. more than 100 words
    if len(secret_text) <= 100:
        for word in words:
            if word == word.upper(
            ):  # If a spy send a message with special words such as SOS, SAVE ME etc. (i.e. message in capital letters) then app displays an appropriate message.
                print "IMPORTANT MESSAGE: " + secret_text
            else:
                print "\nRecieved secret message is: " + secret_text
                print "Your secret message has been saved!"

    else:
        print friends[sender].salutation + friends[
            sender].name + " " + "is speaking too much."

        del friends[sender]
        print "Spy has been deleted."
        print "Now your friend list is:"
        item_number = 0
        for friend in friends:
            print '%d. %s %s' % (item_number + 1, friend.salutation,
                                 friend.name)
            item_number = item_number + 1

# Maintain the average number of words spoken by a spy everytime you receive a message from a particular spy.

    def show_avg():
        sender = select_a_friend()
        print "Total number of words: " + str((friends[sender].chats_avg)[0])
        print "Number of chats: " + str((friends[sender].chats_avg)[1])
        print "Average number of words spoken by spy friend: " + str(
            (friends[sender].chats_avg)[0] / float(
                (friends[sender].chats_avg)[1]))

    show_avg()
Exemplo n.º 27
0
def send_message():

    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? ")
    if len(text):
        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!"
    else:
        print "no message to encode"
Exemplo n.º 28
0
def read_message():  #Decoding the secret message

    sender = select_a_friend()
    output_path = raw_input(
        "What is the name of the file?"
    )  #Asking for the file name that contain secret message
    secret_text = Steganography.decode(output_path)
    new_chat = ChatMessage(secret_text, False)
    friends[sender].chats.append(new_chat)

    print "Your secret message has been saved!"
    special_words = ['SOS', 'SAVE ME', "HELP",
                     "DANGER"]  #These are the distress signal
    if secret_text.upper() == 'SOS' or secret_text.upper(
    ) == 'SAVE ME' or secret_text.upper(
    ) == 'HELP':  #code words for the spy being in danger
        print 'Hand tight, help has been dispatched \n'
Exemplo n.º 29
0
def send_message():

    # making user choose the friend to send message
    friend_choice = select_friend()

    # implementing steganography encoding message
    original_image = raw_input("What is the name of the image?")
    output_path = raw_input("What name do you want for image your friend receive?")
    text = raw_input("What do you want to say?")
    Steganography.encode(original_image, output_path, text)

    new_chat = ChatMessage(text, True)

    # saving the text message sent by user to corresponding friend
    friends[friend_choice].chats.append(new_chat)

    print "Your secret message image is ready!"
def read_message():

    #please select a friend
    sender = select_a_friend()

    output_path = raw_input("Now, tell me the name of the file")
    try:
        #message is decoded here
        secret_text = Steganography.decode(output_path)
    except:
        print 'Your message is not valid'
        return
    new_chat = ChatMessage(secret_text, False)

    friends[sender].chats.append(new_chat)
    if secret_text.upper() in special_message:
        print "We are on our way!\n"