Python Forum
Playfair cipher encoder and decoder - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: Playfair cipher encoder and decoder (/thread-5803.html)



Playfair cipher encoder and decoder - nuttinserious - Oct-22-2017

Hi, I have to make a program that is like the playfair cipher which encodes a specific text and a second program that decodes the text. The instructions state: For the encoding program, the file will contain the
plaintext (original un-encoded text) and a new file will be created
containing the encoded text.
The decoding program will again ask for a keyword and the name of a file
containing encoded text. It should produce a file containing the
un-encoded plaintext.

I currently have this:
import itertools

f = open("Encode.txt", "w+")
key = input("Enter Key: ").replace("j", "i")
alphabet = 'abcdefghiklmnopqrstuvwxyz'
slots =
for x in itertools.chain(key, alphabet):
if not x in slots: slots.append(x)

matrix = [slots[i:i + 5] for i in range(0, 25, 5)]
f.write(str(matrix))
print(str(matrix))
f.close()

and I'm not even sure if that is right, in serious need of help Huh Cry


RE: Playfair cipher encoder and decoder - buran - Oct-23-2017

Please, don't remove content from posts. If you found solution of your problem, just acknowledge that in new post and eventually share the solution for benefit of others who may face the same problem.