Skip to content

Commit 3ed9f88

Browse files
author
Kieran BW
committed
minor changes
1 parent 009719c commit 3ed9f88

File tree

7 files changed

+98
-125
lines changed

7 files changed

+98
-125
lines changed

Python.SymEncryptorV2.py

Lines changed: 85 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
Year 2017
44
55
This is an symmetric encryption algorithm. It is a more glorified version of a
6-
substitution cipher. However, some substitutions are added that do not
6+
substitution cipher. However, some substitutions are added that do not
77
correspond to a letter to try and confuse anyone trying to break the cipher
88
"""
99

1010
# ENCRYPTOR V2.2.2
1111
# Kieran (MIT License)
1212

1313
"""
14-
Being pseudorandom, the random libary perhaps isn't the best for an encryption
14+
Being pseudorandom, the random library perhaps isn't the best for an encryption
1515
machine but this is more proof of concept
1616
"""
1717
import random
@@ -23,106 +23,105 @@
2323
uppercase. The only punctuation allowed is '.' and ' ' to improve readability of
2424
the output
2525
"""
26-
alphabet = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q',
27-
'R','S','T','U','V','W','X','Y','Z',' ','.','0','1','2','3','4','5',
28-
'6','7','8','9']
26+
alphabet = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q',
27+
'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', '.', '0', '1', '2', '3', '4', '5',
28+
'6', '7', '8', '9']
2929

3030
# THE ENCRYPTION KEYS
3131
encryptionKeyA = ['KYL', 'JTD', 'RXQ', 'WEF', 'BRG', 'AWS', 'LHM', 'KWK', 'UIK',
32-
'EHQ', 'GVT', 'UKE', 'WLV', 'HGI', 'KRI', 'PUE', 'HJB', 'FVL',
33-
'ORQ', 'ROD', 'JKH', 'QOT', 'QLU', 'YSJ', 'JNT', 'PBC', 'HNC',
34-
'YSG', 'NKI', 'SGU', 'OXG', 'WCG', 'HAB', 'GVC', 'UEJ', 'SGB',
35-
'SWE', 'YKX']
32+
'EHQ', 'GVT', 'UKE', 'WLV', 'HGI', 'KRI', 'PUE', 'HJB', 'FVL',
33+
'ORQ', 'ROD', 'JKH', 'QOT', 'QLU', 'YSJ', 'JNT', 'PBC', 'HNC',
34+
'YSG', 'NKI', 'SGU', 'OXG', 'WCG', 'HAB', 'GVC', 'UEJ', 'SGB',
35+
'SWE', 'YKX']
3636
encryptionKeyB = ['IDY', 'CBS', 'YSP', 'HTA', 'IGR', 'OBH', 'QEY', 'HCQ', 'RWB',
37-
'CJC', 'RRD', 'MDO', 'JIF', 'QHH', 'MYL', 'NLK', 'PIB', 'SMD',
38-
'HNH', 'LBD', 'CIY', 'SXE', 'AEW', 'LFV', 'MVV', 'YQU', 'WUI',
39-
'LRW', 'UYY', 'RUC', 'SUR', 'OOR', 'WQE', 'KAX', 'LFB', 'XBO',
40-
'GWF', 'WSY']
37+
'CJC', 'RRD', 'MDO', 'JIF', 'QHH', 'MYL', 'NLK', 'PIB', 'SMD',
38+
'HNH', 'LBD', 'CIY', 'SXE', 'AEW', 'LFV', 'MVV', 'YQU', 'WUI',
39+
'LRW', 'UYY', 'RUC', 'SUR', 'OOR', 'WQE', 'KAX', 'LFB', 'XBO',
40+
'GWF', 'WSY']
4141
falseEncryption = ['EQS', 'NPO', 'PKA', 'FGA', 'BWR', 'PIE', 'IFE', 'GUM', 'XIN',
42-
'EHT', 'MDU', 'CAX', 'OBY', 'MQP', 'PYF', 'PVI', 'GOS', 'YYG',
43-
'FTQ', 'NDT', 'YHK', 'JVJ', 'NPV', 'BHE', 'JLJ', 'DUN', 'EPU',
44-
'RKX', 'LOM', 'HVD', 'GIG', 'KRE', 'VVJ', 'HFY', 'QJU', 'VXB',
45-
'OIF', 'XCE']
42+
'EHT', 'MDU', 'CAX', 'OBY', 'MQP', 'PYF', 'PVI', 'GOS', 'YYG',
43+
'FTQ', 'NDT', 'YHK', 'JVJ', 'NPV', 'BHE', 'JLJ', 'DUN', 'EPU',
44+
'RKX', 'LOM', 'HVD', 'GIG', 'KRE', 'VVJ', 'HFY', 'QJU', 'VXB',
45+
'OIF', 'XCE']
4646

4747
# RUN AGAIN - THE MODULAR FUNCTION TO ASK THE USER WHETHER THEY WOULD LIKE TO
4848
# RUN THE CODE AGAIN
49-
def runAgain(alphabet,encryptionKeyA,encryptionKeyB,falseEncryption):
49+
def runAgain(alphabet, encryptionKeyA, encryptionKeyB, falseEncryption):
5050

51-
try:
52-
play = str(input ("\nWould you like to run again? \n\n>>>"))
53-
play = play.lower()
54-
play = play[0]
55-
except:
56-
print ("\n!PLEASE TYPE 'YES' OR 'NO'!")
57-
runAgain(alphabet,encryptionKeyA,encryptionKeyB,falseEncryption)
58-
if play == "y":
59-
main(alphabet,encryptionKeyA,encryptionKeyB,falseEncryption)
60-
elif play == "n":
61-
print ("Ok")
62-
else:
63-
print ("\n!PLEASE TYPE 'YES' OR 'NO'!")
64-
runAgain(alphabet,encryptionKeyA,encryptionKeyB,falseEncryption)
51+
try:
52+
play = str(input("\nWould you like to run again? \n\n>>>"))
53+
play = play.lower()
54+
play = play[0]
55+
except:
56+
print("\n!PLEASE TYPE 'YES' OR 'NO'!")
57+
runAgain(alphabet, encryptionKeyA, encryptionKeyB, falseEncryption)
58+
if play == "y":
59+
main(alphabet, encryptionKeyA, encryptionKeyB, falseEncryption)
60+
elif play == "n":
61+
print("Ok")
62+
else:
63+
print("\n!PLEASE TYPE 'YES' OR 'NO'!")
64+
runAgain(alphabet, encryptionKeyA, encryptionKeyB, falseEncryption)
6565

6666
# THE ENCRYPTION PROCESS
67-
def encrypt(alphabet,encryptionKeyA,encryptionKeyB,falseEncryption):
68-
# Get user input
69-
string = input("\nPlease input the message to encrypt \n\n>>>")
70-
string = string.upper()
71-
# The encrypted text
72-
new = ""
73-
for x in range(len(string)):
74-
for i in range(38):
75-
# Text the charachter is in the allowed alphabet
76-
if string[x] == alphabet[i]:
77-
encryptChoice = systemRandom.randint(0,1)
78-
if encryptChoice == 0:
79-
new = new + encryptionKeyA[i]
80-
elif encryptChoice == 1:
81-
new = new + encryptionKeyB[i]
82-
# Add a random element from the false key
83-
new = new + falseEncryption[systemRandom.randint(0,26)]
84-
print ("\nHere is the new, encrypted message:\n\n"+new)
85-
runAgain(alphabet,encryptionKeyA,encryptionKeyB,falseEncryption)
67+
def encrypt(alphabet, encryptionKeyA, encryptionKeyB, falseEncryption):
68+
# Get user input
69+
string = input("\nPlease input the message to encrypt \n\n>>>")
70+
string = string.upper()
71+
# The encrypted text
72+
new = ""
73+
for x in range(len(string)):
74+
for i in range(38):
75+
# Text the character is in the allowed alphabet
76+
if string[x] == alphabet[i]:
77+
encryptChoice = systemRandom.randint(0, 1)
78+
if encryptChoice == 0:
79+
new = new + encryptionKeyA[i]
80+
elif encryptChoice == 1:
81+
new = new + encryptionKeyB[i]
82+
# Add a random element from the false key
83+
new = new + falseEncryption[systemRandom.randint(0, 26)]
84+
print("\nHere is the new, encrypted message:\n\n"+new)
85+
runAgain(alphabet, encryptionKeyA, encryptionKeyB, falseEncryption)
8686

8787
# THE DECODING PROCESS
88-
def decode(alphabet,encryptionKeyA,encryptionKeyB,falseEncryption):
89-
# Get user input
90-
string = input("\nPlease input the message to decode as it was printed exactly \n\n>>>")
91-
string = string.upper()
92-
# The decoded text
93-
new = ""
94-
for x in range(int(len(string)/3)):
95-
for i in range(38):
96-
# Select the next 'chunk' of text and decrypt
97-
if string[x*3:(x*3)+3] == encryptionKeyA[i]:
98-
new = new + alphabet[i]
99-
elif string[x*3:(x*3)+3] == encryptionKeyB[i]:
100-
new = new + alphabet[i]
101-
print ("\nHere is the original, decoded message:\n\n"+new)
102-
runAgain(alphabet,encryptionKeyA,encryptionKeyB,falseEncryption)
88+
def decode(alphabet, encryptionKeyA, encryptionKeyB, falseEncryption):
89+
# Get user input
90+
string = input("\nPlease input the message to decode as it was printed exactly \n\n>>>")
91+
string = string.upper()
92+
# The decoded text
93+
new = ""
94+
for x in range(int(len(string)/3)):
95+
for i in range(38):
96+
# Select the next 'chunk' of text and decrypt
97+
if string[x*3:(x*3)+3] == encryptionKeyA[i]:
98+
new = new + alphabet[i]
99+
elif string[x*3:(x*3)+3] == encryptionKeyB[i]:
100+
new = new + alphabet[i]
101+
print("\nHere is the original, decoded message:\n\n"+new)
102+
runAgain(alphabet, encryptionKeyA, encryptionKeyB, falseEncryption)
103103

104104
# THE MENU FOR THE PROGRAM
105-
def main(alphabet,encryptionKeyA,encryptionKeyB,falseEncryption):
105+
def main(alphabet, encryptionKeyA, encryptionKeyB, falseEncryption):
106106

107-
print ("\nMain Menu:")
108-
print("Enter the number represented in the brackets to use the function.")
109-
try:
110-
mode = int(input ("\nFunctions:\nEncrypt(0) \nDecode(1) \n\n>>>"))
111-
if mode == 0:
112-
encrypt(alphabet,encryptionKeyA,encryptionKeyB,falseEncryption)
113-
elif mode == 1:
114-
decode(alphabet,encryptionKeyA,encryptionKeyB,falseEncryption)
115-
except:
116-
print ("\n!PLEASE INPUT 0 TO ENCRYPT OR 1 TO DECODE!")
117-
main(alphabet,encryptionKeyA,encryptionKeyB,falseEncryption)
107+
print("\nMain Menu:")
108+
print("Enter the number represented in the brackets to use the function.")
109+
try:
110+
mode = int(input("\nFunctions:\nEncrypt(0) \nDecode(1) \n\n>>>"))
111+
if mode == 0:
112+
encrypt(alphabet, encryptionKeyA, encryptionKeyB, falseEncryption)
113+
elif mode == 1:
114+
decode(alphabet, encryptionKeyA, encryptionKeyB, falseEncryption)
115+
except:
116+
print("\n!PLEASE INPUT 0 TO ENCRYPT OR 1 TO DECODE!")
117+
main(alphabet, encryptionKeyA, encryptionKeyB, falseEncryption)
118118

119-
# THE INITIAL STARTUP PROCESS, SEPERATE FROM THE MENU SO IT ONLY RUNS ONCE
120-
def preStart(alphabet,encryptionKeyA,encryptionKeyB,falseEncryption):
119+
# THE INITIAL STARTUP PROCESS, SEPARATE FROM THE MENU SO IT ONLY RUNS ONCE
120+
def preStart(alphabet, encryptionKeyA, encryptionKeyB, falseEncryption):
121121

122-
print ("Welcome to the encryption machine version 2.2.2!")
123-
print ("Designed and developed by Kieran.")
124-
main(alphabet,encryptionKeyA,encryptionKeyB,falseEncryption)
125-
126-
# THE COMMAND EXCECUTED TO START THE PROGRAM
127-
preStart(alphabet,encryptionKeyA,encryptionKeyB,falseEncryption)
122+
print("Welcome to the encryption machine version 2.2.2!")
123+
print("Designed and developed by Kieran.")
124+
main(alphabet, encryptionKeyA, encryptionKeyB, falseEncryption)
128125

126+
# THE COMMAND EXECUTED TO START THE PROGRAM
127+
preStart(alphabet, encryptionKeyA, encryptionKeyB, falseEncryption)

README.md

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
# Python.SymEncryptorV2
1515

1616

17-
<img src="readme-assets/icons/proj-icon.png" alt="Project Icon" width="100">
17+
<img src="readme-assets/icons/name.png" alt="Project Icon" width="750">
1818

1919
This is an symmetric encryption algorithm. It is a more glorified version of a
20-
substitution cipher. However, some substitutions are added that do not
20+
substitution cipher. However, some substitutions are added that do not
2121
correspond to a letter to try and confuse anyone trying to break the cipher
2222

2323

2424
## Download
2525
### Clone
26-
#### Using The Command Line
26+
#### Using The Command Line
2727
1. Press the Clone or download button in the top right
2828
2. Copy the URL (link)
2929
3. Open the command line and change directory to where you wish to clone to
@@ -32,15 +32,15 @@ correspond to a letter to try and confuse anyone trying to break the cipher
3232
$ git clone https://github.com/[user-name]/[repository]
3333
```
3434

35-
More information can be found at
36-
<https://help.github.com/en/articles/cloning-a-repository>
35+
More information can be found at
36+
<https://help.github.com/en/articles/cloning-a-repository>
3737

3838
#### Using GitHub Desktop
3939
1. Press the Clone or download button in the top right
4040
2. Click open in desktop
4141
3. Choose the path for where you want and click Clone
4242

43-
More information can be found at
43+
More information can be found at
4444
<https://help.github.com/en/desktop/contributing-to-projects/cloning-a-repository-from-github-to-github-desktop>
4545

4646
### Download Zip File
@@ -50,46 +50,20 @@ More information can be found at
5050
3. Copy/ move to the desired location
5151

5252

53-
## Language information
53+
## Language information
5454
### Built for
55-
This program has been written for Python 3 and has been tested with
56-
Python version 3.7.0 <https://www.python.org/downloads/release/python-370/>
57-
on a Windows 10 PC.
55+
This program has been written for Python 3 and has been tested with
56+
Python version 3.7.0 <https://www.python.org/downloads/release/python-370/>
57+
on a Windows 10 PC.
5858
### Other versions
59-
To install Python, go to <https://www.python.org/> and download the latest
60-
version.
59+
To install Python, go to <https://www.python.org/> and download the latest
60+
version.
6161
## How to run
6262
1. Open the .py file in IDLE
6363
2. Run by pressing F5 or by selecting Run> Run Module
6464

6565

66-
## Licence
66+
## Licence
6767
MIT License
6868
Copyright (c) fredhappyface
6969
(See the [LICENSE](/LICENSE.md) for more information.)
70-
71-
72-
<!--
73-
TODO: Add screenshots to readme-assets/screenshots/desktop/ named
74-
screenshot-[number].png
75-
-->
76-
## Screenshots
77-
78-
### Desktop
79-
|Screenshots |
80-
|:-: |
81-
|<img src="readme-assets/screenshots/desktop/screenshot-1.png" alt="Screenshot 1" width="600">|
82-
|<img src="readme-assets/screenshots/desktop/screenshot-2.png" alt="Screenshot 2" width="600">|
83-
|<img src="readme-assets/screenshots/desktop/screenshot-3.png" alt="Screenshot 3" width="600">|
84-
85-
86-
87-
## Limited Support
88-
Expect this project to be supported for approximately 6 months (for bug-fixes
89-
only). Note that this is not guaranteed. Create an issue for bugs (as this
90-
project is carried out in spare time, you may have to wait for a few days)
91-
92-
<img src="readme-assets/support/partial.png" alt="Limited Support" width="600">
93-
94-
95-

readme-assets/icons/name.png

11.6 KB
Loading

readme-assets/icons/proj-icon.png

3.68 KB
Loading

readme-assets/support/full.png

-20.2 KB
Binary file not shown.

readme-assets/support/none.png

-16.1 KB
Binary file not shown.

readme-assets/support/partial.png

-17.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)