def test_stegano(): path = "/tmp/image/a.jpg" output_path = "/tmp/image/b.jpg" text = 'The quick brown fox jumps over the lazy dog.' Steganography.encode(path, output_path, text) secrete_text = Steganography.decode(output_path) assert secrete_text == text
def read_a_message(): sender = select_a_friend() output_path = raw_input("what is the name of the image.") secret_text = Steganography.decode(output_path) chat = chatmessage(secret_text, False) friends[sender].chat.append(chat) if secret_text.upper() == "SOS" or secret_text.upper() == "SAVE ME" or secret_text.upper() == "HELP": print("you will receive help soon...") print("your secret message is saved.")
def read_a_message(): sender = select_friend() output = raw_input( "Jis Tasveer mein message daalna hai uska naam bataiye?") secret_text = Steganography.decode(output) print secret_text if 0 < len(secret_text) < 100: new_chat = ChatMessage(secret_text, True) dhabi[sender].chats.append(new_chat) elif len(secret_text) > 100: print "Boht bol raha tha, Nikal diya G***u ko." del dhabi[sender] else: print "Koi message nahi hai iss image mein" for word in EMERGENCY_MESSAGES: if word == secret_text: print "dhabi musibat mein hai" print colored("Apka secret message save karr liya hai", "blue")
def read_message(): sender = select_a_friend() output_path = raw_input("What is the name of the file?") secret_text = Steganography.decode(output_path) if 0 < len(secret_text.split(" ")) < 100: new_chat = ChatMessage(secret_text, False) print secret_text elif len(secret_text.split(" ")) > 100: del friends[sender] print "Friend deleted because he/she was speaking too much!" else: print "Image doesn't have any messages"
def read_message(): sender = select_a_friend() output_path = raw_input('What is the name of the file?') secret_text = Steganography.decode(output_path) if len(secret_text) > 0: if secret_text == 'SOS' or secret_text == 'Emergency' or secret_text == 'Save Me'\ or secret_text == 'In Trouble': print colored('Help Required', 'red') new_chat = ChatMessage(secret_text, False) friends[sender].chats.append(new_chat) print 'Your secret message has been saved!'
def read_message(): sender = select_friend() output_path = raw_input(colored("What is the name of the file?", "green", "on_grey")) secret_text = Steganography.decode(output_path) if secret_text.upper() in SPECIAL_WORDS: #prints alert for some special words defined by the user print colored("SPY ALERT! SPY ALERT! SPECIAL MESSAGE GENERATED: " + secret_text, 'green', 'on_grey') number = count_words(secret_text) #counts the number of words in the string if number > 50: remove_friend(sender) #removes the friend if the friend speaks more than hundred words else: print secret_text new_chat = ChatMessage(secret_text, False) friends[sender].chats.append(new_chat) print colored("Your secret message has been saved!", "green", "on_grey")
def read_message(): 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].chat.append(new_chat) print 'Sorry ! no secret message to be displayed' print secret_text text_length = len(secret_text) - secret_text.count(" ") if text_length > 100: del friends[sender] if "save me".upper() in secret_text: print "need help" if "alert".upper() in secret_text: print "be active " if "sos".upper() in secret_text: print "Emergency call"
def read_message(): #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) if secret_text in ['BRB']: print "BE RIGHT BACK!!!" elif secret_text in ['HELP']: print "BACKU UP TEAM WILL REACH SOON" elif secret_text in ['SOS']: print "SAVE OUR SHIP" else: print "secret_text" print "Your secret message has been saved !!!!"
def read_message(): sender = select_a_friend() output_path = raw_input("What is the name of the file?") secret_text = Steganography.decode(output_path) print "Your secret message is" + secret_text new_chat = { "message": secret_text, "time": datetime.now(), "sent_by_me": False } friends[sender].chats.append(new_chat) print "Your secret message has been saved!"
def read_a_message(): sender= select_friend() output_path=raw_input("What is tha name of image for output") 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: print "your friend is removed because of overwriting" del friends[sender] else: print "there is no secret message" for shabd in emergency_massages: if shabd== secret_text: print "your friend is in danger" print "Your secret message has been saved!"
def read_a_message(): read = 1 friend_selected = select_a_friend( read) #'read' to print specific message to select a friend if friend_selected != -1: output_path = raw_input("Enter the image name: ") secret_message = Steganography.decode( output_path ) #decode method is used to decrypt the msg from the file. if secret_message != "": print secret_message new_chat = chat(secret_message, False) #saving the secret essage to the chats. friends[friend_selected].chats.append(new_chat) else: print "There is no sercret message." #Handling corner case for no secret message. else: print "Friend not selected" #Handling corner case for wrong input for selection of a friend.
def read_a_message(): sender = select_a_friend() output_image = raw_input("Enter the name of file: ") #Decoding the hidden text from image if os.path.isfile(output_image) == 1: secret_text = Steganography.decode(output_image) new_chat = ChatMessage(secret_text, False) #Check for hidden text inside a image if len(secret_text) > 0: friends[sender].chats.append(new_chat) print new_chat else: print 'Oops Looks like there is no hidden message encoded' exit() else: print 'No such file present' exit()
def read_message(): print "Choose the friend whose message you want to read" sender = select_friend() if len(friends[sender].chats) == 0: print "You have no conversation with %s" % friends[sender].name else: for i in range(len(friends[sender].chats)): print(friends[sender].chats[i].message) 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 beem saved\n" print "Your message is '%s'" % secret_text
def read_message(): sender = select_friend() #calling function select_friend output_path = raw_input("What is the name of the file?") secret_text = Steganography.decode(output_path) print bcolors.BOLD + secret_text new_chat = { "message": secret_text, "time": datetime.now(), "sent_by_me": False } friends[sender]['chat'].append(new_chat) print "Your secret message has been saved!"
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!"
def read_message(id): msg = 0 senderr = [] for i in chats: c = 0 if i.recever == id: senderr.append(i.sender) # print "You have message from " + i.sender msg = 1 else: c = c + 1 print "\nYou have message From " + senderr[-1] + ".\n" if msg == 0: print "You don't Have any message." if msg == 1: selected_frnd = select_a_frnd() for i in chats: c = 0 if i.recever == frnd_list[selected_frnd].name: sender = i.sender else: c = c + 1 output_path = raw_input("Which image you want to decode? ") text = Steganography.decode(output_path) print "\n Secret text is ::: " + text time = chats[c].time print Fore.BLUE + " " + str( time) + Fore.RED + " " + " Sender : " + sender print Fore.BLACK + "Your secret message has been saved!\n" # appending the message to new_chat new_chat = chatmessage(text, False, frnd_list[selected_frnd].name, id) frnd_list[selected_frnd].chat.append(new_chat)
def read_message(): sender = select_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!" if secret_text == "": print"SORRY !!!! sender did not send any secret message to you" elif secret_text.upper()=="SM": print"save me ." elif secret_text.upper()=="ALERT": print"please be alerted ." elif secret_text.upper()=="SOS": print"This is a special message.clear the path ASAP" else: print secret_text text_length= len(secret_text)- secret_text.count(' ') print str("Message has ")+str(text_length)+str(" words")
def read_message(): #please select a friend sender = select_a_friend() output_path = raw_input("Now, tell me the name of the file") #message is decoded here secret_text = Steganography.decode(output_path) new_chat = ChatMessage(secret_text, False) friends[sender].chats.append(new_chat) if secret_text == "QUIT": print "Please Quit it" else: #printing your message that you sent print secret_text
def send_message(index): text = raw_input( colored('Enter the message you want to send', 'green', 'on_grey')) input = raw_input( colored('select the image for encoding', 'green', 'on_grey')) output = 'output.jpg' Steganography.encode(input, output, text) temp_friend = {'chats': {'message': [], 'sent_by_me': False, 'date': []}} #using the date time library date = datetime.now() dated = date.strftime("%a, %d %b %Y %H:%M") #using the steganography library text = Steganography.decode(output) temp_friend = friends[index] temp_friend['chats']['sent_by_me'] = True temp_friend['chats']['message'].append(text) temp_friend['chats']['date'].append(dated) print colored('the message has been sent to ', 'yellow', 'on_grey'), colored(temp_friend['name'], 'red', 'on_grey')
def read_message(): sender = select_friend() #Ask the user for the name of the image they want to decode the message from output_path = raw_input("What is the name of the file?") secret_text = Steganography.decode(output_path) new_chat = ChatMsg(secret_text, False) #Append the chat dictionary to chats key for the particular friend friends[sender].chats.append(new_chat) print "Your secret message has been saved!" + secret_text list_of = secret_text.split(" ") for ele in list_of: if ele == "SOS" or ele == "sos" or ele == "SAVE" or ele == "save" or ele == "help" or ele == "HELP": # If a spy sends a message with special words such as SOS or SAVE ME or HELP ,then display a message and exit the application. print "Spy is in danger!" exit()
def read_message(): sender = select_a_friend() output_path = raw_input('Abe chl khajoor fotuu ka naam bta') secret_text = Steganography.decode(output_path) new_chat = ChatMessage(secret_text, False) friends[sender].chats.append(new_chat) print "Abe oh kaaliaa ,Tera khana mene kha lia .....aur han Message mere pas hai re!" print secret_text text_length = len(secret_text) - secret_text.count(" ") if text_length > 100: del friends[sender] if "save me".upper() in secret_text: print "Spyjan zara dhyaan de ....apke ek bhai bandhu ko sahayta chahiye !" if "alert".upper() in secret_text: print "Abe oh ghonchuu , Dhyan rkh " if "sos".upper() in secret_text: print "Emergency call"
def read_message(): name = load_friend() read_message = open('chats.csv', 'r') read_m = csv.reader(read_message) #PRINTING CHAT TRANSCRIPT WITH DIFFERENT COLORS init() for row in read_m: if name == row[0]: print(Back.WHITE) print(Fore.RED + '%s' % (row[0]) + Fore.BLACK + ' %s' % (row[1]) + Fore.BLUE + ' %s' % (row[2])) print(Back.RESET + Fore.RESET) #STEGANOGRAPHY output = raw_input('\nEnter Name of the Image you want to decode!\n') message = Steganography.decode(output) print('Secret message: %s' % (message)) if message.upper() == 'SOS': print('HELP YOUR FRIEND RIGHT NOW\n')
def read_a_message(): sender = select_a_friend() output_path = raw_input("What is the name of the file?") secret_text = Steganography.decode(output_path) print(secret_text) # add the chat to sender 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) print("Your secret message has been saved.") # writing chats in chats.csv 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])
def decode_images(in_dir): # Verify that in_dir path is valid if not os.path.isdir(in_dir): print "in_dir path is invalid.." return None # Count number of image files in in_dir num_image_files = 0 files = [] for a_file in os.listdir(in_dir): a_file = in_dir + "/" + a_file try: im = Image.open(a_file) files.insert(num_image_files, a_file) num_image_files += 1 except IOError as err: print "file:", a_file, " is not an image" msg = "" num_files = len(files) count = 1 print "" for a_file in files: secret_text = Steganography.decode(a_file) if secret_text != None: print "Decoded", count, "of", num_files, "files..." count = count + 1 msg += secret_text print "\nHere's your message...\n\n" inp = raw_input( "\nOK.. I have decoded the files.. Do you want to see your message?\n\n" ) if inp == 'y' or inp == 'yes': print print print "######", msg, "######" last_inp = raw_input( "\nPSST.. !! Do you want me to tell you one more secret before I exit..?\n\n" ) if last_inp == 'y' or last_inp == 'yes': print "GO look at http://localhost:7885/static/index.html"
def read_message(): sender = select_friend() if (sender == "error"): print Fore.RED + "Wrong Choice" + Fore.RESET else: while (True): encrypted_image = raw_input("Please provide the encryted image to decode") if re.match(imageexpr, encrypted_image, flags=0) is not None: break else: print Fore.RED + "Image name must be alpha numeric and image extension must be .jpg" + Fore.RESET try: secret_message = Steganography.decode(encrypted_image) print "The secret message is: " + secret_message # emergency messages for i in emergency: if i == secret_message.upper(): print Fore.RED + "Your emergency message has been handled" + Fore.RESET chats = friend_list[sender].get_chats() all_message = secret_message for chat in chats: if not chat['send_by_me']: all_message = all_message + " " + chat['message'] avg_words = len(all_message.split()) if (avg_words > 100): print Fore.RED + "Error!! Spy speaking too much. Removing the spy from friend list...." + Fore.RESET del friend_list[sender] else: print Fore.GREEN + "Hello you are speaking fine. your average words speaked till date is: " + str(avg_words) + Fore.RESET new_chat = { 'message': secret_message, 'time': datetime.now(), 'send_by_me': False } friend_list[sender].get_chats().append(new_chat) print Fore.GREEN + "Message saved" + Fore.RESET except: print Fore.RED + "Sry either image is not available or the image does not contain any valid message" + Fore.RESET
def read_message(): try: 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) # TO STORE THE NO. OF WORDS SPOKEN BY A USER for word in friends[sender].chats: words_spoken = word.avg_words + len(secret_text.split()) # VARIABLE TO STORE THE DETAILS OF THE NEW CHAT DATA new_chat = ChatMessage(secret_text, False, words_spoken) friends[sender].chats.append(new_chat) print("Your secret message has been decoded and saved!") except IOError: print( "\033[1;34m No such file or directory found!!\nEnter a valid path and try again!! \033[1m;34m" )
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] print "Messages are deleted after crossing limit" else: print "image doesn't have any message" for word in EMERGENCY_MESSAGES: if word == secret_text: print "In trouble" print "Your secret message has been saved!"
def read_message(): friend_choice = select_friend() output_path = raw_input("What is the name of the file?") secret_text = Steganography.decode(output_path) new_chat = { "message": secret_text, "time": datetime.now(), "sent_by_me": False } friends[friend_choice]['chats'].append(new_chat) if (len(secret_text)>100): friends.remove(friends[friend_choice]) print "friend deleted" \ "" else: print secret_text
def read_a_message(name): global flag position = select_a_friend(name) if position == "null": return () else: from steganography.steganography import Steganography f_name = spy_list[name]['friends'].keys()[position] print "Friend %s selected\n" % (f_name) d_img_name = raw_input("What is the name of the output file you want to decode?: ") d_path = "C:\Users\Kanak Goel\Desktop" overall_path = d_path+"\\"+ d_img_name from datetime import datetime date = datetime.now().strftime('%Y-%m-%d %H:%M:%S') print "come down...................................." secret_text = Steganography.decode(overall_path) if len(secret_text) == 0: print "Image has no secret message" else: print "\nYour secret text is: " + secret_text
def read_message(): sender = slect_a_friend() output_path = raw_input("enter the name of image:") secrate_text = Steganography.decode(output_path) print("your secreate message is:%s" % (secrate_text)) #=========================(Fn for read the file)================================ def load_friend(): with open('db.csv', 'rb') as friends_data: reader = csv.reader(friends_data) for row in reader: new_friends = { 'name': row[0], 'salutation': row[1], 'age': row[2], 'rating': row[3], 'is_online': row[4], } friends.append(new_friends)
def read_message(): print("Choose the friend whose message you want to read") friend_choice = select_friend() read_message1 = [] Read_chat_time = time.ctime() #read_message1.append(send_message()) read_message1.append(Read_chat_time) output_path = input("What is the output_path name") message = Steganography.decode(output_path) new_chat_message = chatMessage(message, False) friends[friend_choice].chats.append(new_chat_message) if len(friends[friend_choice].chats) == 0: print("You have no conversation with %s" % friends[friend_choice].name) else: for i in range(len(friends[friend_choice].chats)): print(friends[friend_choice].chats[i].message) print("read_message_time :- %s " % (read_message1))
def read_message(): select_friend = select_frnd() # index value output_path = raw_input('Which image you want to decode ? ' ) # asking the user for an input of image secret_text = Steganography.decode(output_path) # decoding message num = int(secret_text[:1] ) # checking if the right person is decoding the message or not if num == select_friend: secret_text = secret_text.replace(str(num), '') print 'Secret text is:' + Fore.RED + secret_text # Displaying for the user print(Style.RESET_ALL) new_chat = ChatMessage(secret_text, time.strftime("%d,%m,%H"), spy.name, friends[select_friend].name) friends[select_friend].chats.append( new_chat) # appending the friend chat detail print 'Your secret message has been saved...' # message user else: print "SORRY you can't decode this" #message to user
def read_message(): frnd = select_friend() sender = frnd avgg = 0 flag = 0 while True: output_path = raw_input('Name of image which contains secret message:') pattern = '^[a-zA-Z0-9\s]+\.jpg$' if re.match(pattern, output_path) != None: # Handling I/O error try: # Decryption of encrypted image secret_text = Steganography.decode(output_path) pattern = '^[a-zA-z]+$' # Handling cases of image having no secret message. if re.match(pattern, secret_text)!= None: print 'This is your message:' print secret_text avg = len(secret_text) new_chat = ChatMessage(secret_text, False, avg, sender) friends[frnd].chats.append(new_chat) print "Your secret message has been saved!" break else: print 'This file doesn\'t contain any secret message.' print 'Try again.' except IOError: print 'No such file present in the directory.' else: print 'Invalid image name.. ' print 'It must end with .jpg association.' print 'Try Again!' sleep(0.8) if new_chat.sender == 1: flag += 1 av = len(new_chat.message) / flag avgg = avgg + av if avgg > 100: friends.pop(new_chat.sender) print 'He has been removed.' print 'He has been speaking too much.'