Please do not use any existing code, it would be amazing if you could code it yourself
Can i get Playfair Cipher for python 3 that encrypts a message and decrypts a message or exits when prompted by the user, get input from user to encrypt. could you possibly make it as simple as you can without losing functionality.
please include comments, that would help me better understand
Example of PlayFair Cipher:
https://en.wikipedia.org/wiki/Playfair_cipher
PLAYFAIR CIPHER CODE IN PYTHON
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 25 11:59:40 2020
@author: HP
"""
key1=input("Enter key : ")
key1=key1.replace(" ", "")
key1=key1.upper()
def matrix(x,y,initial):
return [[initial for i in range(x)] for j in range(y)]
result=list()
for c in key1: #storing key1
if c not in result:
if c=='J':
result.append('I')
else:
result.append(c)
flag=0
for i in range(65,91): #storing other character
if chr(i) not in result:
if i==73 and chr(74) not in result:
result.append("I")
flag=1
elif flag==0 and i==73 or i==74:
pass
else:
result.append(chr(i))
k=0
play_matrix=matrix(5,5,0) #initialize matrix
for i in range(0,5): #making matrix
for j in range(0,5):
play_matrix[i][j]=result[k]
k+=1
def locindex(c): #get location of each character
loc=list()
if c=='J':
c='I'
for i ,j in enumerate(play_matrix):
for k,l in enumerate(j):
if c==l:
loc.append(i)
loc.append(k)
return loc
def encrypt(): #Encryption
msg1=str(input("ENTER MSG:"))
msg1=msg1.upper()
msg1=msg1.replace(" ", "")
i=0
for s in range(0,len(msg1)+1,2):
if s<len(msg1)-1:
if msg1[s]==msg1[s+1]:
msg1=msg1[:s+1]+'X'+msg1[s+1:]
if len(msg1)%2!=0:
msg1=msg1[:]+'X'
print("CIPHER TEXT:",end=' ')
while i<len(msg1):
loc=list()
loc=locindex(msg1[i])
loc1=list()
loc1=locindex(msg1[i+1])
if loc[1]==loc1[1]:
print("{}{}".format(play_matrix[(loc[0]+1)%5][loc[1]],play_matrix[(loc1[0]+1)%5][loc1[1]]),end='
')
elif loc[0]==loc1[0]:
print("{}{}".format(play_matrix[loc[0]][(loc[1]+1)%5],play_matrix[loc1[0]][(loc1[1]+1)%5]),end='
')
else:
print("{}{}".format(play_matrix[loc[0]][loc1[1]],play_matrix[loc1[0]][loc[1]]),end='
')
i=i+2
def decrypt(): #decryption
msg1=str(input("ENTER CIPHER TEXT:"))
msg1=msg1.upper()
msg1=msg1.replace(" ", "")
print("PLAIN TEXT:",end=' ')
i=0
while i<len(msg1):
loc=list()
loc=locindex(msg1[i])
loc1=list()
loc1=locindex(msg1[i+1])
if loc[1]==loc1[1]:
print("{}{}".format(play_matrix[(loc[0]-1)%5][loc[1]],play_matrix[(loc1[0]-1)%5][loc1[1]]),end='
')
elif loc[0]==loc1[0]:
print("{}{}".format(play_matrix[loc[0]][(loc[1]-1)%5],play_matrix[loc1[0]][(loc1[1]-1)%5]),end='
')
else:
print("{}{}".format(play_matrix[loc[0]][loc1[1]],play_matrix[loc1[0]][loc[1]]),end='
')
i=i+2
while(1):
choice=int(input("\n 1.Encryption \n 2.Decryption: \n
3.EXIT"))
if choice==1:
encrypt()
elif choice==2:
decrypt()
elif choice==3:
exit()
else:
print("Choose correct choice")
OUTPUT
Enter key : play fair example
1.Encryption
2.Decryption:
3.EXIT
ENTER MSG:hide the gold in the tree stump
CIPHER TEXT: BM OD ZB XD NA BE KU DM UI XM MO UV IF
1.Encryption
2.Decryption:
3.EXIT
Please do not use any existing code, it would be amazing if you could code it...
Can i get Playfair Cipher for python 3 that encrypts a message and decrypts it, could you possibly make it as simple as you can without losing functionality. please include comments, that would help me better understand Example of PlayFair Cipher: https://en.wikipedia.org/wiki/Playfair_cipher The Playfair cipher uses a 5 by 5 table containing a key word or phrase. Memorization of the keyword and 4 simple rules was all that was required to create the 5 by 5 table and use the...
Its a c++ program and please use basic code, I am a begineer.
Please do show aall the steps
Random monoalphabet cipher. The Caesar cipher, which shifts all letters by a fixed amount, is far too easy to crack. Here is a better idea. As the key, don't use numbers but words. Suppose the key word is FEATHER. Then first remove duplicate letters, yielding FEATHR, and append the other letters of the alphabet in reverse order: Now encrypt the letters...
. Please write a function that will do the following Decryption of a message encrypted with a substitution cipher given cipher text only without any key Please provide comments on each line of code outlining what that line is doing. Note: Only the Function is to be written, all user inputs i.e the text to be decrypted will be entered earlier in the program. Code must be written in C and be able to be compiled using GCC If any...
JAVA Problem: With the recent news about data breaches and different organizations having their clients’ information being exposed, it is becoming more and more important to find ways to protect our sensitive data. In this program we will develop a simple tool that helps users generate strong passwords, encrypt and decrypt data using some cyphering techniques. You will need to create two classes. The first class is your driver for the application and contains the main method. Name this class...
CIS 221 Loan Calculator Enhancement Introduction You are a systems analyst working for a company that provides loans to customers. Your manager has asked you to enhance and correct their existing Loan Calculator program, which is designed to calculate monthly and total payments given the loan amount, the annual interest rate, and the duration of the loan. Although the current version of the program (hereby termed the “As Is” version) has some functionality, there are several missing pieces, and the...
Code In Python
Well Document Code Every Line Please
* You cannot use any external Python libraries. You can, of course, import the libraries that are included in the standard Python installation though. * Your software must use selection (if, if/ else, etc.) and repetitive (for, while, etc) control structures and have programmer defined functions. * Make sure you understand the code you submit since you will be expected to answer questions about it. The way the program should work...
Code In Python Well Document Code Every Line Please 5
Stars
* You cannot use any external Python libraries. You can, of course, import the libraries that are included in the standard Python installation though. * Your software must use selection (if, if/ else, etc.) and repetitive (for, while, etc) control structures and have programmer defined functions. * Make sure you understand the code you submit since you will be expected to answer questions about it. The way the program...
Code In Python Well Document Code Every Line
Please
* You cannot use any external Python libraries. You can, of course, import the libraries that are included in the standard Python installation though. * Your software must use selection (if, if/ else, etc.) and repetitive (for, while, etc) control structures and have programmer defined functions. * Make sure you understand the code you submit since you will be expected to answer questions about it. The way the program should work...
Could anyone please help with this Python code assignment? In this programming assignment you are to create a program called numstat.py that reads a series of integer numbers from a file and determines and displays the following: The name of the file. The sum of the numbers. The count of how many numbers are in the file. The average of the numbers. The average is the sum of the numbers divided by how many there are. The maximum value. The...
Please write code using Python.
Rubric
Assignment Solution Total: 100 pts
Program successfully retrieves and validates user input 15
pts
Morse Code Function Created 10 pts
Function Uses Parameters to get input message 15 pts
Function successfully converts passed message to Morse Code
and returns the Morse Code equivalent of message 45 pts
Program calls Morse Code function and outputs the result of
the function (i.e. the actual Morse Code) 15 pts
Main Function Requirement
Part 2 MUST have a...