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'
def send_message(spy): friend_choice = select_friend() valid_set = ['T','I'] text = raw_input("Please Enter your Message") choice = validators.get_alpha('Want to send message as text or hide it in image?(T for text/I for Image) ',1,2,valid_set) if choice == 'I': try: original_image = raw_input("What is the name of the image?") output_path = 'output.jpg' try: Steganography.encode(original_image, output_path, text) except IOError: print 'File doesnt exist' except: print 'Operation Unsuccessful' return 0 new_chat = ChatMessage(spy_id=spy.id, friend_id=friends[friend_choice].id,message=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!"