Skip to content

Commit 114f884

Browse files
committed
- Changed CaesarCipher.encrypt formatting output
- Changes to docstrings - Updated `README.md` Signed-off-by: schlopp96 <[email protected]>
1 parent 3de6fd4 commit 114f884

File tree

2 files changed

+38
-14
lines changed

2 files changed

+38
-14
lines changed

MyCaesarCipher/main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def encrypt(text: str,
2525
2626
- Generates encrypted form of :param:`text` using the Caesar-Cipher algorithm.
2727
- If no :param:`key` is provided, a random integer value is generated.
28+
- Optionally disable output of encrypted text results to stdout by toggling :param:`stdout_output` to `False`.
2829
2930
---
3031
@@ -63,7 +64,7 @@ def encrypt(text: str,
6364
else:
6465
output += char
6566

66-
info: str = f'> Original Msg : {text}\n\n\t- Shift-key : {key}\n\n\t- Encrypted Result: {output}\n'
67+
info: str = f'> Original Msg : {text}\n\n> Shift-key : {key}\n\n> Encrypted Result: {output}\n'
6768

6869
if stdout_output:
6970
print(info)
@@ -74,7 +75,7 @@ def encrypt(text: str,
7475
def decrypt(text: str, stdout_output: bool = True) -> dict[str, int]:
7576
"""Decrypt Caesar-Cipher encrypted messages and return dictionary of all possible results.
7677
77-
- Optionally disable output of all decrypted text and corresponding shift-keys by toggling :param:`stdout_output` to `False`.
78+
- Optionally disable output of decrypted text results and corresponding shift-keys to stdout by toggling :param:`stdout_output` to `False`.
7879
7980
---
8081

README.md

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,16 @@
7575
>>> msg = 'Test Cipher'
7676
>>> cipher.encrypt(text=msg, key=200, stdout_output=True)
7777

78+
------------------------------------
79+
7880
> Original Msg : Test Cipher
79-
- Shift-Key : 200
80-
- Encrypted Result: Lwkl Uahzwj
81+
82+
> Shift-Key : 200
83+
84+
> Encrypted Result: Lwkl Uahzwj
8185
```
8286

83-
- Therefore the final encrypted result of "Test Cipher" using a shift-key of 200 is:
87+
- Therefore the final encrypted result of "Test Cipher" using a shift key of 200 is:
8488

8589
- "**`LwklfUahzwj`**".
8690

@@ -89,21 +93,41 @@
8993
- ```python
9094
>>> cipher.encrypt('Test Cipher', stdout_output=True)
9195

96+
------------------------------------
97+
9298
> Original Msg : Test Cipher
93-
- Shift-key : 19
94-
- Encrypted Result: Mxlm Vbiaxk
9599

100+
> Shift-key : 19
101+
102+
> Encrypted Result: Mxlm Vbiaxk
103+
```
104+
105+
---
106+
107+
- ```python
96108
>>> cipher.encrypt('Test Cipher', stdout_output=True)
97109

110+
------------------------------------
111+
98112
> Original Msg : Test Cipher
99-
- Shift-key : 24
100-
- Encrypted Result: Rcqr Agnfcp
101113

114+
> Shift-key : 24
115+
116+
> Encrypted Result: Rcqr Agnfcp
117+
```
118+
119+
---
120+
121+
- ```python
102122
>>> cipher.encrypt('Test Cipher', stdout_output=True)
103123

124+
------------------------------------
125+
104126
> Original Msg : Test Cipher
105-
- Shift-key : 4
106-
- Encrypted Result: Xiwx Gmtliv
127+
128+
> Shift-key : 4
129+
130+
> Encrypted Result: Xiwx Gmtliv
107131
```
108132

109133
---
@@ -116,10 +140,9 @@
116140
>>> from MyCaesarCipher import CaesarCipher
117141

118142
>>> cipher = CaesarCipher() # Create new class instance.
119-
>>> code = 'Ozno Xdkczm'
120-
>>> decryption = cipher.decrypt(text=code, stdout_output=True)
143+
>>> decryption = cipher.decrypt(text='Ozno Xdkczm', stdout_output=True)
121144

122-
>>> print(decryption)
145+
------------------------------------
123146

124147
> Decrypted Shift-Key 0 : Ozno Xdkczm
125148

0 commit comments

Comments
 (0)