-
Notifications
You must be signed in to change notification settings - Fork 1
/
encipher.py
54 lines (47 loc) · 1.51 KB
/
encipher.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Author: James Campbell
# What: Encrypts text using pigpen cipher
# Requirements: Python 3.x and above
import json
from colorama import Fore, Back, Style
with open('jsondata.json') as f:
jsondict = json.loads(f.read())
# //// tests
# print(jsondict['a'])
pypigpen = """
------------------------------------
PYPIGPEN ENCIPHER / DECIPHER TOOL
------------------------------------
,.
(_|,.
,' /, )_______ _
__j o``-' `.'-)'
(") \\'
`-j P I G P E N |
`-._( /
|_\ |--^. /
/_]'|_| /_)_/
/_]' /_]'
------------------------------------
"""
print(pypigpen)
print(Fore.CYAN+'Welcome.')
print(Fore.YELLOW+'\nThis will print a cipher to a text file called cipher.txt. \nUse decipher.py to reverse.'+Fore.RESET)
print('------------------------------------\n')
helloworld = input("What do you want to encipher? (use . for new line):\n")
# get ready for output
# clear
import os
os.system('cls' if os.name == 'nt' else 'clear')
# start output here
print('Output:\n')
with open('./cipher.txt',"w") as f:
for letter in helloworld:
# print("\n{}".format(letter))
if letter == '.':
print('\n')
f.write('\n')
continue
letter = letter.lower()
print(jsondict[letter], end="")
f.write(jsondict[letter]+' ')
exit('\nthanks for playing\nsaved as cipher.txt\n')