Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # MD Harrington Kent London UK 12-09-2024 Time 1:56
- # Facebook https://www.facebook.com/mark.harrington.14289
- # Now Improved much more This is just so cool
- # Instagram https://www.instagram.com/markukh2021/
- # Homesite (Still busy with this at present ) https://eliteprojects.x10host.com/
- # Github https://github.com/markh2024 && https://github.com/markh2016
- # Codeshare https://codeshare.io/codes
- # To most this would appear as a graph but , ha , ha Alas it is not and so I win again, eh , eh , eh
- # Who would never even think anything of this ?
- # Any one thought of this ?
- # Send a graph to who you wish to communicate in private with and extract the real hidden code within
- # Have fun , I wont expand on what else you can do with this yet , Im going to let you think
- #!/usr/bin/env python3
- # MD Harrington Kent London UK 12-09-2024 Time 1:56
- import time
- import matplotlib.pyplot as plt
- import numpy as np
- import datetime
- import os # For clearing the screen
- import platform # To detect the OS
- from PIL import Image, PngImagePlugin # For embedding metadata in the image
- # Function to print text in a slow typewriter style with color support
- def slow_print(text, color=None):
- if color:
- print(f"\033[{color}m", end="") # Set the color (e.g., '91' for red)
- for char in text:
- print(char, end='', flush=True)
- time.sleep(0.05) # Slow print effect
- if color:
- print("\033[0m", end="") # Reset color to default after text
- print() # New line after the text
- # Function to plot the graph of ASCII values of a sentence, save as an image, and embed metadata
- def plot_ascii_graph(sentence):
- ascii_values = [ord(char) for char in sentence]
- x = np.arange(len(ascii_values)) # X-axis corresponds to sentence length
- y = np.array(ascii_values)
- fig, ax = plt.subplots()
- line, = ax.plot(x, y, 'r-', linewidth=1) # Plot with red line, width=1
- ax.set_title('ASCII Value Plot of the Sentence MD Harrington Kent London')
- ax.set_xlabel('Character Position')
- ax.set_ylabel('ASCII Value')
- ax.set_ylim([0, 127]) # Y-axis max value is 127 (ASCII max value)
- ax.grid(True)
- # Add a movable crosshair
- vertical_line = ax.axvline(color='k', linestyle='--') # Vertical crosshair
- horizontal_line = ax.axhline(color='k', linestyle='--') # Horizontal crosshair
- # Fixed label near X-axis title (right above 'Character Position')
- label = ax.text(0.2, 0.1, "", color="blue", fontsize=12, ha='center',
- transform=ax.transAxes)
- def on_move(event):
- if event.inaxes == ax:
- # Update the position of the crosshair
- vertical_line.set_xdata(event.xdata)
- horizontal_line.set_ydata(event.ydata)
- plt.draw()
- def on_click(event):
- if event.inaxes == ax:
- # Find the nearest data point
- index = int(round(event.xdata))
- if 0 <= index < len(sentence):
- character = sentence[index]
- label.set_text(f"'{character}' at index {index}")
- plt.draw()
- # Connect the mouse events to their handlers
- fig.canvas.mpl_connect('motion_notify_event', on_move)
- fig.canvas.mpl_connect('button_press_event', on_click)
- plt.show()
- # Save the plot as an image file (ascplot.png)
- img_filename = "ascplot.png"
- fig.savefig(img_filename, dpi=300)
- print("Graph saved as ascplot.png with ASCII metadata. Please wait 2 seconds.")
- time.sleep(2)
- # Embed ASCII values into the image metadata
- img = Image.open(img_filename)
- meta = PngImagePlugin.PngInfo()
- # Convert ASCII values to a comma-separated string and add as metadata
- ascii_values_str = ','.join(map(str, ascii_values))
- meta.add_text("ASCII Values", ascii_values_str)
- img.save(img_filename, "PNG", pnginfo=meta)
- # Function to display the menu
- def display_menu():
- slow_print("The Program allows me to send a graph to anyone without them knowing what that message is \n", color="93")
- slow_print("1: Provide a sentence of no longer than 20 words", color="91")
- slow_print("2: Plot a graph of the sentence you provided", color="92")
- slow_print("3: Quit", color="93")
- # Function to clear the screen based on the OS
- def clear_screen():
- # Detect the OS and clear screen appropriately
- if platform.system() == "Windows":
- os.system('cls')
- else:
- os.system('clear')
- def main():
- sentence = ""
- while True:
- clear_screen() # Clear the screen before showing the menu
- display_menu()
- choice = input("Enter your choice (1-3): ")
- if choice == '1':
- while True:
- user_input = input("Please enter a sentence (max 20 words): ")
- word_count = len(user_input.split())
- if word_count > 20:
- print(f"Your sentence has {word_count} words, which exceeds the 20-word limit.")
- retry = input("Do you want to re-enter the sentence? (y/n): ")
- if retry.lower() != 'y':
- break
- else:
- sentence = user_input
- slow_print(f"Your sentence has {word_count} words.", color="91")
- break
- elif choice == '2':
- if sentence:
- slow_print(sentence, color="92")
- plot_ascii_graph(sentence) # Plot the graph, save it, and embed metadata
- else:
- slow_print("No sentence provided. Please choose option 1 first.", color="94")
- elif choice == '3':
- current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
- slow_print(f"Program exited gracefully, thank you MD Harrington. {current_time}", color="92")
- time.sleep(2)
- clear_screen()
- break
- else:
- print("Invalid choice. Please select again.")
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement