Skip to content

Commit

Permalink
- Changed CaesarCipher.encrypt formatting output
Browse files Browse the repository at this point in the history
- Changes to docstrings
- Updated `README.md`

Signed-off-by: schlopp96 <71921821+schlopp96@users.noreply.github.com>
  • Loading branch information
schlopp96 committed Feb 12, 2023
1 parent 3de6fd4 commit 114f884
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 14 deletions.
5 changes: 3 additions & 2 deletions MyCaesarCipher/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def encrypt(text: str,
- Generates encrypted form of :param:`text` using the Caesar-Cipher algorithm.
- If no :param:`key` is provided, a random integer value is generated.
- Optionally disable output of encrypted text results to stdout by toggling :param:`stdout_output` to `False`.
---
Expand Down Expand Up @@ -63,7 +64,7 @@ def encrypt(text: str,
else:
output += char

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

if stdout_output:
print(info)
Expand All @@ -74,7 +75,7 @@ def encrypt(text: str,
def decrypt(text: str, stdout_output: bool = True) -> dict[str, int]:
"""Decrypt Caesar-Cipher encrypted messages and return dictionary of all possible results.
- Optionally disable output of all decrypted text and corresponding shift-keys by toggling :param:`stdout_output` to `False`.
- Optionally disable output of decrypted text results and corresponding shift-keys to stdout by toggling :param:`stdout_output` to `False`.
---
Expand Down
47 changes: 35 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,16 @@
>>> msg = 'Test Cipher'
>>> cipher.encrypt(text=msg, key=200, stdout_output=True)

------------------------------------

> Original Msg : Test Cipher
- Shift-Key : 200
- Encrypted Result: Lwkl Uahzwj

> Shift-Key : 200

> Encrypted Result: Lwkl Uahzwj
```

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

- "**`LwklfUahzwj`**".

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

------------------------------------

> Original Msg : Test Cipher
- Shift-key : 19
- Encrypted Result: Mxlm Vbiaxk

> Shift-key : 19

> Encrypted Result: Mxlm Vbiaxk
```

---

- ```python
>>> cipher.encrypt('Test Cipher', stdout_output=True)

------------------------------------

> Original Msg : Test Cipher
- Shift-key : 24
- Encrypted Result: Rcqr Agnfcp

> Shift-key : 24

> Encrypted Result: Rcqr Agnfcp
```

---

- ```python
>>> cipher.encrypt('Test Cipher', stdout_output=True)

------------------------------------

> Original Msg : Test Cipher
- Shift-key : 4
- Encrypted Result: Xiwx Gmtliv

> Shift-key : 4

> Encrypted Result: Xiwx Gmtliv
```

---
Expand All @@ -116,10 +140,9 @@
>>> from MyCaesarCipher import CaesarCipher

>>> cipher = CaesarCipher() # Create new class instance.
>>> code = 'Ozno Xdkczm'
>>> decryption = cipher.decrypt(text=code, stdout_output=True)
>>> decryption = cipher.decrypt(text='Ozno Xdkczm', stdout_output=True)

>>> print(decryption)
------------------------------------

> Decrypted Shift-Key 0 : Ozno Xdkczm

Expand Down

0 comments on commit 114f884

Please sign in to comment.