Severity: Warning
Message: fopen(/tmp/ci_sessionl3i0c7l4fihtt6ohnnlt6nv4l2anhof8): failed to open stream: No space left on device
Filename: drivers/Session_files_driver.php
Line Number: 176
Backtrace:
File: /var/www/html/application/controllers/Project.php
Line: 10
Function: __construct
File: /var/www/html/index.php
Line: 311
Function: require_once
Severity: Warning
Message: session_start(): Failed to read session data: user (path: /tmp)
Filename: Session/Session.php
Line Number: 143
Backtrace:
File: /var/www/html/application/controllers/Project.php
Line: 10
Function: __construct
File: /var/www/html/index.php
Line: 311
Function: require_once
This packet gives us an idea of how to build a project which will convert your plain secret text to ciphertext and vice versa.
Modules used:
tkinter
First of all we need to make sure that our python IDE has pip installed in it if not download get-pip.py file from the web in the same directory as Python is installed and then we can install required modules in our IDE Terminal using
pip install command
and In general we use cryptography for secrecy of data and convert into ciphertext and we use Tkinter in this application as it provides us simple way to create GUI elements using widgets found in TK where we give the user an option/Task whether they want to encrypt/decrypt a particular text by entering e(or)d in the Tk application and dynamically entering the cipher text/secret text for the application in the resulting application and we can either swap the letters or add certain ASCII values to change the meaning of the text.
from tkinter import messagebox, simpledialog, Tk
def is_even(num):
return num % 2 == 0
def get_even_letters(msg):
even_letters = []
for counter in range(0, len(msg)):
if is_even(counter):
even_letters.append(msg[counter])
return even_letters
def get_odd_letters(msg):
odd_letters = []
for counter in range(0, len(msg)):
if not is_even(counter):
odd_letters.append(msg[counter])
return odd_letters
def swap_letters(msg):
letter_list = []
if not is_even(len(msg)):
msg = msg + 'x'
even_letters = get_even_letters(msg)
odd_letters = get_odd_letters(msg)
for counter in range(0, int(len(msg) / 2)):
letter_list.append(odd_letters[counter])
letter_list.append(even_letters[counter])
new_msg = ''.join(letter_list)
return new_msg
def get_task():
task = simpledialog.askstring('Task', 'Do you want to encrypt or decrypt?')
return task
def get_msg():
message = simpledialog.askstring('Message', 'Enter the secret message: ')
return message
root = Tk()
while True:
task = get_task()
if task == 'e':
msg = get_msg()
e = swap_letters(msg)
messagebox.showinfo('Ciphertext of the secret message is:', e)
elif task == 'd':
msg = get_msg()
d = swap_letters(msg)
messagebox.showinfo('Plaintext of the secret message is:', d)
else:
break
root.mainloop()
Submitted by Krishna Prasad Deekonda (krishnadeekonda)
Download packets of source code on Coders Packet
Comments