# MyCaesarCipher
> Simple cryptographic substitution-based cipher for encoding plaintext.
---
## About
- The [Caesar Cipher](https://en.wikipedia.org/wiki/Caesar_cipher) is one of the most simple and well-known encryption techniques.
- Each letter in the plaintext entry is replaced by a letter found at a certain number of positions down the alphabet.
- This project was created as an exercise while I was taking the ["Cracking Codes with Python"](https://inventwithpython.com/cracking/) course - which I _highly_ recommend for both beginners and experienced Python programmers interested in cryptography!
---
## Installation
### Using pip _(Recommended)_
> **_Easiest_ method.**
> _Highly recommended over manual installation._
- Run the following to install _**`MyCaesarCipher`**_ using `pip`:
- ```python
pip install MyCaesarCipher
```
- You should now be able to import/run _**`MyCaesarCipher`**_ within your Python environment by entering the following:
- ```python
>>> from MyCaesarCipher import CaesarCipher
...
```
- Done!
---
### Manual Installation
> **_Not_ recommended.**
> _Only use this method if you are unable to install using `pip`_.
1. Before use, navigate to the intended installation location, and create a new directory.
2. Please only do one of the following:
- **A.** Clone repository with the git client of your preference.
- **B.** Download and extract the source code `zip` archive from the ["releases"](https://github.com/schlopp96/MyCaesarCipher/releases) page to the newly created directory.
3. Install all dependencies for this package within the installation directory using the following command:
- ```python
pip install -r requirements.txt
```
4. _**(Optional)**_ move the installation directory to **`"~Python/Libs/site_packages/"`** to be able to import this package to a Python environment like any other importable package.
- Done!
---
## Usage
- Within a Python environment or **`.py`** project, simply import the _**`MyCaesarCipher`**_ module to start encryption/decryption of ciphers.
### Text Encryption
- For encrypting text, use the **`CaesarCipher.encrypt`** class method:
- ```python
>>> from MyCaesarCipher import CaesarCipher
>>> cipher = CaesarCipher() # Create new class instance.
>>> txt = 'Test Cipher'
>>> cipher.encrypt(text=txt, key=15, stdout_output=True)
------------------------------------
> Original Txt : Test Cipher
> Shift-Key : 15
> Encrypted Result: Ithi Rxewtg
```
- Therefore the final encrypted result of "Test Cipher" using a shift key of 15 is:
- "**`Ithi Rxewtg`**".
- Note that the `key` parameter is _optional_, and if not provided, a random key between 1 and 25 will be generated:
- ```python
>>> cipher.encrypt('Test Cipher', stdout_output=True)
------------------------------------
> Original Txt : Test Cipher
> Shift-key : 19
> Encrypted Result: Mxlm Vbiaxk
```
---
- ```python
>>> cipher.encrypt('Test Cipher', stdout_output=True)
------------------------------------
> Original Txt : Test Cipher
> Shift-key : 24
> Encrypted Result: Rcqr Agnfcp
```
---
- ```python
>>> cipher.encrypt('Test Cipher', stdout_output=True)
------------------------------------
> Original Txt : Test Cipher
> Shift-key : 4
> Encrypted Result: Xiwx Gmtliv
```
---
### Text Decryption
- For decrypting text, use the **`CaesarCipher.decrypt`** class method:
- ```python
>>> from MyCaesarCipher import CaesarCipher
>>> cipher = CaesarCipher() # Create new class instance.
>>> decryption = cipher.decrypt(text='Ozno Xdkczm', stdout_output=True)
------------------------------------
> Decrypted Shift-Key 0 : Ozno Xdkczm
> Decrypted Shift-Key 1 : Nymn Wcjbyl
> Decrypted Shift-Key 2 : Mxlm Vbiaxk
> Decrypted Shift-Key 3 : Lwkl Uahzwj
> Decrypted Shift-Key 4 : Kvjk Tzgyvi
> Decrypted Shift-Key 5 : Juij Syfxuh
> Decrypted Shift-Key 6 : Ithi Rxewtg
> Decrypted Shift-Key 7 : Hsgh Qwdvsf
> Decrypted Shift-Key 8 : Grfg Pvcure
> Decrypted Shift-Key 9 : Fqef Oubtqd
> Decrypted Shift-Key 10 : Epde Ntaspc
> Decrypted Shift-Key 11 : Docd Mszrob
> Decrypted Shift-Key 12 : Cnbc Lryqna
> Decrypted Shift-Key 13 : Bmab Kqxpmz
> Decrypted Shift-Key 14 : Alza Jpwoly
> Decrypted Shift-Key 15 : Zkyz Iovnkx
> Decrypted Shift-Key 16 : Yjxy Hnumjw
> Decrypted Shift-Key 17 : Xiwx Gmtliv
> Decrypted Shift-Key 18 : Whvw Flskhu
> Decrypted Shift-Key 19 : Vguv Ekrjgt
> Decrypted Shift-Key 20 : Uftu Djqifs
> Decrypted Shift-Key 21 : Test Cipher # <-- Correct Result
> Decrypted Shift-Key 22 : Sdrs Bhogdq
> Decrypted Shift-Key 23 : Rcqr Agnfcp
> Decrypted Shift-Key 24 : Qbpq Zfmebo
> Decrypted Shift-Key 25 : Paop Yeldan
```
- The **`CaesarCipher.decrypt`** method will return all possible shifted-key variations of the given encrypted text as a dictionary.
- This is NOT printed to stdout even if the `stdout_output` parameter is set to `True`.
- ```python
{'Ozno Xdkczm': 0, 'Nymn Wcjbyl': 1, 'Mxlm Vbiaxk': 2, 'Lwkl Uahzwj': 3, 'Kvjk Tzgyvi': 4, 'Juij Syfxuh': 5, 'Ithi Rxewtg': 6, 'Hsgh Qwdvsf': 7, 'Grfg Pvcure': 8, 'Fqef Oubtqd': 9, 'Epde Ntaspc': 10, 'Docd Mszrob': 11, 'Cnbc Lryqna': 12, 'Bmab Kqxpmz': 13, 'Alza Jpwoly': 14, 'Zkyz Iovnkx': 15, 'Yjxy Hnumjw': 16, 'Xiwx Gmtliv': 17, 'Whvw Flskhu': 18, 'Vguv Ekrjgt': 19, 'Uftu Djqifs': 20, 'Test Cipher': 21, 'Sdrs Bhogdq': 22, 'Rcqr Agnfcp': 23, 'Qbpq Zfmebo': 24, 'Paop Yeldan': 25}
```
- **_Generally_**, the _most legible_ key output will be the correct decrypted text (assuming the encrypted text was legible initially).
- Regardless, the correct output **MUST** be one of the output values due to the limitations of the algorithm being tied to the length of the alphabet [26] and the number of possible integers [0-9].
- This is also the reason why the algorithm is not recommended for serious real-world cryptography use cases, as it is rather simple to decipher Caesar-Cipher encrypted text.
---
## Contact
- If you have any questions, comments, or concerns that cannot be alleviated through the [project's GitHub repository](https://github.com/schlopp96/MyCaesarCipher), please feel free to contact me through my email address:
- `schloppdaddy@gmail.com`
Raw data
{
"_id": null,
"home_page": "https://github.com/schlopp96/MyCaesarCipher",
"name": "MyCaesarCipher",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "cryptography,Caesar-Cipher,Caesar,Cipher,encryption,decryption,cryptographic,module,script,encrypt,decrypt,python",
"author": "schlopp96",
"author_email": "schloppdaddy@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/41/ce/6c034ba5b3c3744264f45fef577f7695a56907b9c2a6b1add48ea38378c0/MyCaesarCipher-0.4.1.tar.gz",
"platform": null,
"description": "# MyCaesarCipher\n\n> Simple cryptographic substitution-based cipher for encoding plaintext.\n\n---\n\n## About\n\n- The [Caesar Cipher](https://en.wikipedia.org/wiki/Caesar_cipher) is one of the most simple and well-known encryption techniques.\n\n - Each letter in the plaintext entry is replaced by a letter found at a certain number of positions down the alphabet.\n\n- This project was created as an exercise while I was taking the [\"Cracking Codes with Python\"](https://inventwithpython.com/cracking/) course - which I _highly_ recommend for both beginners and experienced Python programmers interested in cryptography!\n\n---\n\n## Installation\n\n### Using pip _(Recommended)_\n\n> **_Easiest_ method.**\n> _Highly recommended over manual installation._\n\n- Run the following to install _**`MyCaesarCipher`**_ using `pip`:\n\n - ```python\n pip install MyCaesarCipher\n ```\n\n- You should now be able to import/run _**`MyCaesarCipher`**_ within your Python environment by entering the following:\n\n - ```python\n >>> from MyCaesarCipher import CaesarCipher\n ...\n ```\n\n- Done!\n\n---\n\n### Manual Installation\n\n> **_Not_ recommended.**\n> _Only use this method if you are unable to install using `pip`_.\n\n1. Before use, navigate to the intended installation location, and create a new directory.\n\n2. Please only do one of the following:\n\n - **A.** Clone repository with the git client of your preference.\n - **B.** Download and extract the source code `zip` archive from the [\"releases\"](https://github.com/schlopp96/MyCaesarCipher/releases) page to the newly created directory.\n\n3. Install all dependencies for this package within the installation directory using the following command:\n\n - ```python\n pip install -r requirements.txt\n ```\n\n4. _**(Optional)**_ move the installation directory to **`\"~Python/Libs/site_packages/\"`** to be able to import this package to a Python environment like any other importable package.\n\n- Done!\n\n---\n\n## Usage\n\n- Within a Python environment or **`.py`** project, simply import the _**`MyCaesarCipher`**_ module to start encryption/decryption of ciphers.\n\n### Text Encryption\n\n- For encrypting text, use the **`CaesarCipher.encrypt`** class method:\n\n - ```python\n >>> from MyCaesarCipher import CaesarCipher\n\n >>> cipher = CaesarCipher() # Create new class instance.\n >>> txt = 'Test Cipher'\n >>> cipher.encrypt(text=txt, key=15, stdout_output=True)\n\n ------------------------------------\n\n > Original Txt : Test Cipher\n\n > Shift-Key : 15\n\n > Encrypted Result: Ithi Rxewtg\n ```\n\n- Therefore the final encrypted result of \"Test Cipher\" using a shift key of 15 is:\n\n - \"**`Ithi Rxewtg`**\".\n\n- Note that the `key` parameter is _optional_, and if not provided, a random key between 1 and 25 will be generated:\n\n - ```python\n >>> cipher.encrypt('Test Cipher', stdout_output=True)\n\n ------------------------------------\n\n > Original Txt : Test Cipher\n\n > Shift-key : 19\n\n > Encrypted Result: Mxlm Vbiaxk\n ```\n\n ---\n\n - ```python\n >>> cipher.encrypt('Test Cipher', stdout_output=True)\n\n ------------------------------------\n\n > Original Txt : Test Cipher\n\n > Shift-key : 24\n\n > Encrypted Result: Rcqr Agnfcp\n ```\n\n ---\n\n - ```python\n >>> cipher.encrypt('Test Cipher', stdout_output=True)\n\n ------------------------------------\n\n > Original Txt : Test Cipher\n\n > Shift-key : 4\n\n > Encrypted Result: Xiwx Gmtliv\n ```\n\n---\n\n### Text Decryption\n\n- For decrypting text, use the **`CaesarCipher.decrypt`** class method:\n\n - ```python\n >>> from MyCaesarCipher import CaesarCipher\n\n >>> cipher = CaesarCipher() # Create new class instance.\n >>> decryption = cipher.decrypt(text='Ozno Xdkczm', stdout_output=True)\n\n ------------------------------------\n\n > Decrypted Shift-Key 0 : Ozno Xdkczm\n\n > Decrypted Shift-Key 1 : Nymn Wcjbyl\n\n > Decrypted Shift-Key 2 : Mxlm Vbiaxk\n\n > Decrypted Shift-Key 3 : Lwkl Uahzwj\n\n > Decrypted Shift-Key 4 : Kvjk Tzgyvi\n\n > Decrypted Shift-Key 5 : Juij Syfxuh\n\n > Decrypted Shift-Key 6 : Ithi Rxewtg\n\n > Decrypted Shift-Key 7 : Hsgh Qwdvsf\n\n > Decrypted Shift-Key 8 : Grfg Pvcure\n\n > Decrypted Shift-Key 9 : Fqef Oubtqd\n\n > Decrypted Shift-Key 10 : Epde Ntaspc\n\n > Decrypted Shift-Key 11 : Docd Mszrob\n\n > Decrypted Shift-Key 12 : Cnbc Lryqna\n\n > Decrypted Shift-Key 13 : Bmab Kqxpmz\n\n > Decrypted Shift-Key 14 : Alza Jpwoly\n\n > Decrypted Shift-Key 15 : Zkyz Iovnkx\n\n > Decrypted Shift-Key 16 : Yjxy Hnumjw\n\n > Decrypted Shift-Key 17 : Xiwx Gmtliv\n\n > Decrypted Shift-Key 18 : Whvw Flskhu\n\n > Decrypted Shift-Key 19 : Vguv Ekrjgt\n\n > Decrypted Shift-Key 20 : Uftu Djqifs\n\n > Decrypted Shift-Key 21 : Test Cipher # <-- Correct Result\n\n > Decrypted Shift-Key 22 : Sdrs Bhogdq\n\n > Decrypted Shift-Key 23 : Rcqr Agnfcp\n\n > Decrypted Shift-Key 24 : Qbpq Zfmebo\n\n > Decrypted Shift-Key 25 : Paop Yeldan\n ```\n\n- The **`CaesarCipher.decrypt`** method will return all possible shifted-key variations of the given encrypted text as a dictionary.\n - This is NOT printed to stdout even if the `stdout_output` parameter is set to `True`.\n\n - ```python\n {'Ozno Xdkczm': 0, 'Nymn Wcjbyl': 1, 'Mxlm Vbiaxk': 2, 'Lwkl Uahzwj': 3, 'Kvjk Tzgyvi': 4, 'Juij Syfxuh': 5, 'Ithi Rxewtg': 6, 'Hsgh Qwdvsf': 7, 'Grfg Pvcure': 8, 'Fqef Oubtqd': 9, 'Epde Ntaspc': 10, 'Docd Mszrob': 11, 'Cnbc Lryqna': 12, 'Bmab Kqxpmz': 13, 'Alza Jpwoly': 14, 'Zkyz Iovnkx': 15, 'Yjxy Hnumjw': 16, 'Xiwx Gmtliv': 17, 'Whvw Flskhu': 18, 'Vguv Ekrjgt': 19, 'Uftu Djqifs': 20, 'Test Cipher': 21, 'Sdrs Bhogdq': 22, 'Rcqr Agnfcp': 23, 'Qbpq Zfmebo': 24, 'Paop Yeldan': 25}\n ```\n\n- **_Generally_**, the _most legible_ key output will be the correct decrypted text (assuming the encrypted text was legible initially).\n\n- Regardless, the correct output **MUST** be one of the output values due to the limitations of the algorithm being tied to the length of the alphabet [26] and the number of possible integers [0-9].\n - This is also the reason why the algorithm is not recommended for serious real-world cryptography use cases, as it is rather simple to decipher Caesar-Cipher encrypted text.\n\n---\n\n## Contact\n\n- If you have any questions, comments, or concerns that cannot be alleviated through the [project's GitHub repository](https://github.com/schlopp96/MyCaesarCipher), please feel free to contact me through my email address:\n\n - `schloppdaddy@gmail.com`\n\n\n",
"bugtrack_url": null,
"license": "",
"summary": "Simple cryptographic substitution-based cipher for encoding plaintext.",
"version": "0.4.1",
"split_keywords": [
"cryptography",
"caesar-cipher",
"caesar",
"cipher",
"encryption",
"decryption",
"cryptographic",
"module",
"script",
"encrypt",
"decrypt",
"python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "efa16a41a79eeb273eed337b8e6de3d7382ed491c08e7a9aec1bf2d759a50c80",
"md5": "dbecbcf49ed09dcbd1e4023ce4ee2000",
"sha256": "94a1fb9f371c6dc41199a51b8636e67e3e90047bbe2d0abb6796ca4774a5b2b6"
},
"downloads": -1,
"filename": "MyCaesarCipher-0.4.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "dbecbcf49ed09dcbd1e4023ce4ee2000",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 19357,
"upload_time": "2023-04-12T16:19:10",
"upload_time_iso_8601": "2023-04-12T16:19:10.484217Z",
"url": "https://files.pythonhosted.org/packages/ef/a1/6a41a79eeb273eed337b8e6de3d7382ed491c08e7a9aec1bf2d759a50c80/MyCaesarCipher-0.4.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "41ce6c034ba5b3c3744264f45fef577f7695a56907b9c2a6b1add48ea38378c0",
"md5": "e45882f7129e64ccf35a280ca007d4ba",
"sha256": "9200d1c0e2c6291f959e42ff7c6f43c629196d22bcd497a650c98a8f4911b912"
},
"downloads": -1,
"filename": "MyCaesarCipher-0.4.1.tar.gz",
"has_sig": false,
"md5_digest": "e45882f7129e64ccf35a280ca007d4ba",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 18821,
"upload_time": "2023-04-12T16:19:13",
"upload_time_iso_8601": "2023-04-12T16:19:13.383458Z",
"url": "https://files.pythonhosted.org/packages/41/ce/6c034ba5b3c3744264f45fef577f7695a56907b9c2a6b1add48ea38378c0/MyCaesarCipher-0.4.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-12 16:19:13",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "schlopp96",
"github_project": "MyCaesarCipher",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "mycaesarcipher"
}