# Periodic Encryption
Classical cryptography, enhanced by chemistry !
## Summary
This package allows you to encrypt and decrypt messages by the mean of `Vigenere Cipher` and `Periodic Table of Elements`.
Here is a quick example :
```py
from periodicencryption import vc, en # importing the vigenerecipher and encryption modules
message = "Hello, World!"
row = vc.generate_row() #table row (i.e. which characters are allowed to be encrypted)
encrypted, puk, prk = en.encrypt_keys_auto(row, message)
print(encrypted)
print(f"public key : {puk}")
print(f"private key : {prk}")
decrypted = en.decrypt(row, encrypted, puk, prk)
print(decrypted)
```
```
AeVvco6q&C'qOjPj!yTFgtXtbh
public key : 74.9215HafniumArsec86
private key : HafniumAsrec
Hello, World!
```
## Table of contents
1. [Installation](#installation)
2. [In a nutshell how does it work](#in-a-nutshell-how-does-it-work)
3. [Package Documentation](#package-documentation)
- [Encryption sub-package](#encryption-sub-package)
- [generate_keys](#generate_keys)
- [encrypt_keys_manual](#encrypt_keys_manual)
- [encrypt_keys_auto](#encrypt_keys_auto)
- [decrypt](#decrypt)
- [Element sub-package](#element-sub-package)
- [CounterElement](#counterelement)
- [get_el_by_number](#get_el_by_number)
- [get_el_by_name](#get_el_by_name)
- [get_el_by_symbol](#get_el_by_symbol)
- [get_last_el](#get_last_el)
- [turn_chr_into_el](#turn_chr_into_el)
- [turn_str_into_el](#turn_str_into_el)
- [turn_el_into_chr](#turn_el_into_chr)
- [turn_el_into_str](#turn_el_into_str)
- [Vigenerecipher sub-package](#vigenerecipher-sub-package)
- [generate_row](#generate_row)
- [generate_table](#generate_-_table)
- [vigenere_encode](#vigenere_-_encode)
- [vigenere_decode](#vigenere_-_decode)
## Installation
Enter the following command :
```sh
pip install periodicencryption
```
Then import the package :
```py
import periodicencryption
```
## In a nutshell how does it work
Strings are made up of characters, those characters have a unique code (generally called ASCII code). As it turns out, elements of the periodic table have number linked to them. So this package basicaly retrieve the chemical elements that share the same numbers as the characters. Then that list of element is encoded using a `Vigenere Cipher`
Also don't worry, characters code that exceed 118 (the highest number amongst the periodic table) are handled using a custom element
## Package Documentation
### Package Structure
The main package is structured like that :
```
periodicencryption
- encryption
- element
- vigenerecipher
```
And there are aliases :
| Sub-package | Alias |
|:---|:---|
| encryption | en |
| element | el |
| vigenerecipher | vc |
Which mean you could either use `from periodicencryption import element` or `from periodicencryption import el`
## Encryption sub-package
This sub-package contain everything related to the Vigenere cipher.<br>
It can be accessed via those two methods :
```py
from periodicencryption import en
from periodicencryption import encryption
```
### generate_keys
```py
generate_keys(string: str) -> tuple[str, str]
```
Generates public and private keys from a string.
#### Args:
- `string` (str): The string to generate the keys from.
#### Raises:
- `ValueError`: If the element list is empty.
#### Returns:
- `tuple[str, str]`: The public and private keys.
---
### encrypt_keys_manual
```py
encrypt_keys_manual(row: str, message: str, public_key: str, private_key: str) -> str
```
Encrypts a message using the Vigenère cipher and the periodic table elements, with the specified keys.
#### Args:
- `row` (str): The row of characters to use (i.e. which characters are allowed to be encrypted).
- `message` (str): The message to encrypt.
- `public_key` (str): The public key.
- `private_key` (str): The private key.
#### Raises:
- `ValueError`: If the public or private key contains duplicates.
- `ValueError`: If the message is empty.
#### Returns:
- `str`: The encrypted message.
---
### encrypt_keys_auto
```py
encrypt_keys_auto(row: str, message: str) -> tuple[str, str, str]
```
Encrypts a message using the Vigenère cipher and the periodic table elements, with automatically generated keys.
#### Args:
- `row` (str): The row of characters to use (i.e. which characters are allowed to be encrypted).
- `message` (str): The message to encrypt.
#### Raises:
- `ValueError`: If the message is empty.
#### Returns:
- `tuple[str, str, str]`: The encrypted message, the public key, and the private key.
---
### decrypt
```py
decrypt(row: str, encoded: str, public_key: str, private_key: str) -> str
```
Decrypts a message using the Vigenère cipher and the periodic table elements.
#### Args:
- `row` (str): The row of characters to use (i.e. which characters are allowed to be encrypted).
- `encoded` (str): The encoded message.
- `public_key` (str): The public key.
- `private_key` (str): The private key.
#### Raises:
- `ValueError`: If the public or private key contains duplicates.
- `ValueError`: If the message is empty.
#### Returns:
- `str`: The decrypted message.
---
## Element sub-package
This sub-package contain everything related to chemical elements.<br>
It can be accessed via those two methods :
```py
from periodicencryption import el
from periodicencryption import element
```
### CounterElement
```py
class CounterElement(pt.core.Element)
```
A custom element class to handle elements with codes out of the periodic table range. It stores the mass (`900 + <loop counter>`) to track how many times the code looped out of the periodic table, and stores the final element used to fit the ASCII code in the table.
#### Args:
- `cnt` (int): The loop counter (i.e., how many times we looped out of range over the periodic table).
- `el` (pt.core.Element): The element that we are able to fit into after looping.
#### Class Methods:
- `split_symbol(symbol: str) -> tuple[str, int]`: Splits a symbol into the element symbol and the counter.
--
### get_el_by_number
```py
get_el_by_number(number: int) -> pt.core.Element
```
Returns the element by its number.
#### Args:
- `number` (int): The number of the element.
#### Returns:
- `pt.core.Element`: The element.
---
### get_el_by_name
```py
get_el_by_name(name: str) -> pt.core.Element
```
Returns the element by its name.
#### Args:
- `name` (str): The name of the element.
#### Returns:
- `pt.core.Element`: The element.
---
### get_el_by_symbol
```py
get_el_by_symbol(symbol: str) -> pt.core.Element
```
Returns the element by its symbol.
#### Args:
- `symbol` (str): The symbol of the element.
#### Returns:
- `pt.core.Element`: The element.
---
### get_last_el
```py
get_last_el() -> pt.core.Element
```
Returns the last element of the periodic table.
#### Returns:
- `pt.core.Element`: The last element.
---
### turn_chr_into_el
```py
turn_chr_into_el(character: chr) -> pt.core.Element
```
Converts a character into an element.
#### Args:
- `character` (chr): The character to convert.
#### Returns:
- `pt.core.Element`: The resulting element.
---
### turn_str_into_el
```py
turn_str_into_el(string: str) -> list[pt.core.Element]
```
Converts a string into a list of elements.
#### Args:
- `string` (str): The string to convert.
#### Returns:
- `list[pt.core.Element]`: The resulting list of elements.
---
### turn_el_into_chr
```py
turn_el_into_chr(element: pt.core.Element) -> chr
```
Converts an element into a character.
#### Args:
- `element` (pt.core.Element): The element to convert.
#### Returns:
- `chr`: The resulting character.
---
### turn_el_into_str
```py
turn_el_into_str(element_list: list[pt.core.Element]) -> str
```
Converts a list of elements into a string.
#### Args:
- `element_list` (list[pt.core.Element]): The list of elements to convert.
#### Returns:
- `str`: The resulting string.
---
## Vigenerecipher sub-package
This sub-package contain everything related to the Vigenere cipher.<br>
It can be accessed via those two methods :
```py
from periodicencryption import vc
from periodicencryption import vigenerecipher
```
### generate_row
```py
generate_row() -> str
```
Generates a row for the Vigenère table.
#### Returns:
- `str`: A string containing letters, digits, special characters, whitespace, and letters with diacritics.
---
### generate_table
```py
generate_table(row: str, public_key: str) -> pd.DataFrame
```
Generates a Vigenère table.
#### Args:
- `row` (str): The row to be used in the table.
- `public_key` (str): The public key to be used in the table.
#### Returns:
- `pd.DataFrame`: The Vigenère table.
---
### vigenere_encode
```py
vigenere_encode(row: str, message: str, public_key: str, private_key: str) -> str
```
Encodes a message using the Vigenère cipher.
#### Args:
- `row` (str): The row to be used in the table.
- `message` (str): The message to be encoded.
- `public_key` (str): The public key to be used in the table.
- `private_key` (str): The private key to be used in the table.
#### Returns:
- `str`: The encoded message.
---
### vigenere_decode
```py
vigenere_decode(row: str, encoded_message: str, public_key: str, private_key: str) -> str
```
Decodes a message using the Vigenère cipher.
#### Args:
- `row` (str): The row to be used in the table.
- `encoded_message` (str): The message to be decoded.
- `public_key` (str): The public key to be used in the table.
- `private_key` (str): The private key to be used in the table.
#### Returns:
- `str`: The decoded message.
---
Raw data
{
"_id": null,
"home_page": "https://github.com/NilsMT/periodic-encryption",
"name": "periodicencryption",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "CRYPTOGRAPHY, SECURITY, PERIODIC TABLE, CHEMICAL, WEIRD",
"author": "NilsMT",
"author_email": "nilsmoreauthomas@gmail.com",
"download_url": null,
"platform": null,
"description": "# Periodic Encryption\r\n\r\nClassical cryptography, enhanced by chemistry !\r\n\r\n## Summary\r\n\r\nThis package allows you to encrypt and decrypt messages by the mean of `Vigenere Cipher` and `Periodic Table of Elements`.\r\n\r\nHere is a quick example :\r\n```py\r\nfrom periodicencryption import vc, en # importing the vigenerecipher and encryption modules\r\n\r\nmessage = \"Hello, World!\"\r\n\r\nrow = vc.generate_row() #table row (i.e. which characters are allowed to be encrypted)\r\n\r\nencrypted, puk, prk = en.encrypt_keys_auto(row, message)\r\n\r\nprint(encrypted)\r\nprint(f\"public key : {puk}\")\r\nprint(f\"private key : {prk}\")\r\n\r\ndecrypted = en.decrypt(row, encrypted, puk, prk)\r\n\r\nprint(decrypted)\r\n```\r\n```\r\nAeVvco6q&C'qOjPj!yTFgtXtbh\r\npublic key : 74.9215HafniumArsec86\r\nprivate key : HafniumAsrec\r\nHello, World!\r\n```\r\n\r\n## Table of contents\r\n\r\n1. [Installation](#installation)\r\n2. [In a nutshell how does it work](#in-a-nutshell-how-does-it-work)\r\n3. [Package Documentation](#package-documentation)\r\n - [Encryption sub-package](#encryption-sub-package)\r\n - [generate_keys](#generate_keys)\r\n - [encrypt_keys_manual](#encrypt_keys_manual)\r\n - [encrypt_keys_auto](#encrypt_keys_auto)\r\n - [decrypt](#decrypt)\r\n - [Element sub-package](#element-sub-package)\r\n - [CounterElement](#counterelement)\r\n - [get_el_by_number](#get_el_by_number)\r\n - [get_el_by_name](#get_el_by_name)\r\n - [get_el_by_symbol](#get_el_by_symbol)\r\n - [get_last_el](#get_last_el)\r\n - [turn_chr_into_el](#turn_chr_into_el)\r\n - [turn_str_into_el](#turn_str_into_el)\r\n - [turn_el_into_chr](#turn_el_into_chr)\r\n - [turn_el_into_str](#turn_el_into_str)\r\n - [Vigenerecipher sub-package](#vigenerecipher-sub-package)\r\n - [generate_row](#generate_row)\r\n - [generate_table](#generate_-_table)\r\n - [vigenere_encode](#vigenere_-_encode)\r\n - [vigenere_decode](#vigenere_-_decode)\r\n\r\n## Installation\r\n\r\nEnter the following command :\r\n```sh\r\npip install periodicencryption\r\n```\r\nThen import the package :\r\n```py\r\nimport periodicencryption\r\n```\r\n\r\n## In a nutshell how does it work\r\n\r\nStrings are made up of characters, those characters have a unique code (generally called ASCII code). As it turns out, elements of the periodic table have number linked to them. So this package basicaly retrieve the chemical elements that share the same numbers as the characters. Then that list of element is encoded using a `Vigenere Cipher`\r\n\r\nAlso don't worry, characters code that exceed 118 (the highest number amongst the periodic table) are handled using a custom element\r\n\r\n## Package Documentation\r\n\r\n### Package Structure\r\n\r\nThe main package is structured like that :\r\n```\r\nperiodicencryption\r\n - encryption\r\n - element\r\n - vigenerecipher\r\n```\r\n\r\nAnd there are aliases :\r\n\r\n| Sub-package | Alias |\r\n|:---|:---|\r\n| encryption | en |\r\n| element | el |\r\n| vigenerecipher | vc |\r\n\r\nWhich mean you could either use `from periodicencryption import element` or `from periodicencryption import el`\r\n\r\n## Encryption sub-package\r\n\r\nThis sub-package contain everything related to the Vigenere cipher.<br>\r\nIt can be accessed via those two methods :\r\n```py\r\nfrom periodicencryption import en\r\nfrom periodicencryption import encryption\r\n```\r\n\r\n### generate_keys\r\n```py\r\ngenerate_keys(string: str) -> tuple[str, str]\r\n```\r\nGenerates public and private keys from a string.\r\n\r\n#### Args:\r\n- `string` (str): The string to generate the keys from.\r\n\r\n#### Raises:\r\n- `ValueError`: If the element list is empty.\r\n\r\n#### Returns:\r\n- `tuple[str, str]`: The public and private keys.\r\n\r\n---\r\n\r\n### encrypt_keys_manual\r\n```py\r\nencrypt_keys_manual(row: str, message: str, public_key: str, private_key: str) -> str\r\n```\r\nEncrypts a message using the Vigen\u00c3\u00a8re cipher and the periodic table elements, with the specified keys.\r\n\r\n#### Args:\r\n- `row` (str): The row of characters to use (i.e. which characters are allowed to be encrypted).\r\n- `message` (str): The message to encrypt.\r\n- `public_key` (str): The public key.\r\n- `private_key` (str): The private key.\r\n\r\n#### Raises:\r\n- `ValueError`: If the public or private key contains duplicates.\r\n- `ValueError`: If the message is empty.\r\n\r\n#### Returns:\r\n- `str`: The encrypted message.\r\n\r\n---\r\n\r\n### encrypt_keys_auto\r\n```py\r\nencrypt_keys_auto(row: str, message: str) -> tuple[str, str, str]\r\n```\r\nEncrypts a message using the Vigen\u00c3\u00a8re cipher and the periodic table elements, with automatically generated keys.\r\n\r\n#### Args:\r\n- `row` (str): The row of characters to use (i.e. which characters are allowed to be encrypted).\r\n- `message` (str): The message to encrypt.\r\n\r\n#### Raises:\r\n- `ValueError`: If the message is empty.\r\n\r\n#### Returns:\r\n- `tuple[str, str, str]`: The encrypted message, the public key, and the private key.\r\n\r\n---\r\n\r\n### decrypt\r\n```py\r\ndecrypt(row: str, encoded: str, public_key: str, private_key: str) -> str\r\n```\r\nDecrypts a message using the Vigen\u00c3\u00a8re cipher and the periodic table elements.\r\n\r\n#### Args:\r\n- `row` (str): The row of characters to use (i.e. which characters are allowed to be encrypted).\r\n- `encoded` (str): The encoded message.\r\n- `public_key` (str): The public key.\r\n- `private_key` (str): The private key.\r\n\r\n#### Raises:\r\n- `ValueError`: If the public or private key contains duplicates.\r\n- `ValueError`: If the message is empty.\r\n\r\n#### Returns:\r\n- `str`: The decrypted message.\r\n\r\n---\r\n\r\n## Element sub-package\r\n\r\nThis sub-package contain everything related to chemical elements.<br>\r\nIt can be accessed via those two methods :\r\n```py\r\nfrom periodicencryption import el\r\nfrom periodicencryption import element\r\n```\r\n\r\n### CounterElement\r\n```py\r\nclass CounterElement(pt.core.Element)\r\n```\r\nA custom element class to handle elements with codes out of the periodic table range. It stores the mass (`900 + <loop counter>`) to track how many times the code looped out of the periodic table, and stores the final element used to fit the ASCII code in the table.\r\n\r\n#### Args:\r\n- `cnt` (int): The loop counter (i.e., how many times we looped out of range over the periodic table).\r\n- `el` (pt.core.Element): The element that we are able to fit into after looping.\r\n\r\n#### Class Methods:\r\n- `split_symbol(symbol: str) -> tuple[str, int]`: Splits a symbol into the element symbol and the counter.\r\n\r\n--\r\n\r\n### get_el_by_number\r\n```py\r\nget_el_by_number(number: int) -> pt.core.Element\r\n```\r\nReturns the element by its number.\r\n\r\n#### Args:\r\n- `number` (int): The number of the element.\r\n\r\n#### Returns:\r\n- `pt.core.Element`: The element.\r\n\r\n---\r\n\r\n### get_el_by_name\r\n```py\r\nget_el_by_name(name: str) -> pt.core.Element\r\n```\r\nReturns the element by its name.\r\n\r\n#### Args:\r\n- `name` (str): The name of the element.\r\n\r\n#### Returns:\r\n- `pt.core.Element`: The element.\r\n\r\n---\r\n\r\n### get_el_by_symbol\r\n```py\r\nget_el_by_symbol(symbol: str) -> pt.core.Element\r\n```\r\nReturns the element by its symbol.\r\n\r\n#### Args:\r\n- `symbol` (str): The symbol of the element.\r\n\r\n#### Returns:\r\n- `pt.core.Element`: The element.\r\n\r\n---\r\n\r\n### get_last_el\r\n```py\r\nget_last_el() -> pt.core.Element\r\n```\r\nReturns the last element of the periodic table.\r\n\r\n#### Returns:\r\n- `pt.core.Element`: The last element.\r\n\r\n---\r\n\r\n### turn_chr_into_el\r\n```py\r\nturn_chr_into_el(character: chr) -> pt.core.Element\r\n```\r\nConverts a character into an element.\r\n\r\n#### Args:\r\n- `character` (chr): The character to convert.\r\n\r\n#### Returns:\r\n- `pt.core.Element`: The resulting element.\r\n\r\n---\r\n\r\n### turn_str_into_el\r\n```py\r\nturn_str_into_el(string: str) -> list[pt.core.Element]\r\n```\r\nConverts a string into a list of elements.\r\n\r\n#### Args:\r\n- `string` (str): The string to convert.\r\n\r\n#### Returns:\r\n- `list[pt.core.Element]`: The resulting list of elements.\r\n\r\n---\r\n\r\n### turn_el_into_chr\r\n```py\r\nturn_el_into_chr(element: pt.core.Element) -> chr\r\n```\r\nConverts an element into a character.\r\n\r\n#### Args:\r\n- `element` (pt.core.Element): The element to convert.\r\n\r\n#### Returns:\r\n- `chr`: The resulting character.\r\n\r\n---\r\n\r\n### turn_el_into_str\r\n```py\r\nturn_el_into_str(element_list: list[pt.core.Element]) -> str\r\n```\r\nConverts a list of elements into a string.\r\n\r\n#### Args:\r\n- `element_list` (list[pt.core.Element]): The list of elements to convert.\r\n\r\n#### Returns:\r\n- `str`: The resulting string.\r\n\r\n---\r\n\r\n## Vigenerecipher sub-package\r\n\r\nThis sub-package contain everything related to the Vigenere cipher.<br>\r\nIt can be accessed via those two methods :\r\n```py\r\nfrom periodicencryption import vc\r\nfrom periodicencryption import vigenerecipher\r\n```\r\n\r\n### generate_row\r\n```py\r\ngenerate_row() -> str\r\n```\r\nGenerates a row for the Vigen\u00c3\u00a8re table.\r\n\r\n#### Returns:\r\n- `str`: A string containing letters, digits, special characters, whitespace, and letters with diacritics.\r\n\r\n---\r\n\r\n### generate_table\r\n```py\r\ngenerate_table(row: str, public_key: str) -> pd.DataFrame\r\n```\r\nGenerates a Vigen\u00c3\u00a8re table.\r\n\r\n#### Args:\r\n- `row` (str): The row to be used in the table.\r\n- `public_key` (str): The public key to be used in the table.\r\n\r\n#### Returns:\r\n- `pd.DataFrame`: The Vigen\u00c3\u00a8re table.\r\n\r\n---\r\n\r\n### vigenere_encode\r\n```py\r\nvigenere_encode(row: str, message: str, public_key: str, private_key: str) -> str\r\n```\r\nEncodes a message using the Vigen\u00c3\u00a8re cipher.\r\n\r\n#### Args:\r\n- `row` (str): The row to be used in the table.\r\n- `message` (str): The message to be encoded.\r\n- `public_key` (str): The public key to be used in the table.\r\n- `private_key` (str): The private key to be used in the table.\r\n\r\n#### Returns:\r\n- `str`: The encoded message.\r\n\r\n---\r\n\r\n### vigenere_decode\r\n```py\r\nvigenere_decode(row: str, encoded_message: str, public_key: str, private_key: str) -> str\r\n```\r\nDecodes a message using the Vigen\u00c3\u00a8re cipher.\r\n\r\n#### Args:\r\n- `row` (str): The row to be used in the table.\r\n- `encoded_message` (str): The message to be decoded.\r\n- `public_key` (str): The public key to be used in the table.\r\n- `private_key` (str): The private key to be used in the table.\r\n\r\n#### Returns:\r\n- `str`: The decoded message.\r\n\r\n---\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Allow you to encrypt & decrypt strings using the periodic table elements",
"version": "1.1.1",
"project_urls": {
"Homepage": "https://github.com/NilsMT/periodic-encryption"
},
"split_keywords": [
"cryptography",
" security",
" periodic table",
" chemical",
" weird"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "cfeeeff3f8e6e37ae55bf3e8ff727ee76b50a4ef85e72682f61ad4f37e2adee5",
"md5": "aa2d1a53cc9c1e2816ba082a644413d9",
"sha256": "c332cbce8db24b333db138f26ff8e9df3517573a12b9b51330c6e5073cef7367"
},
"downloads": -1,
"filename": "periodicencryption-1.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "aa2d1a53cc9c1e2816ba082a644413d9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 9169,
"upload_time": "2024-12-14T17:13:07",
"upload_time_iso_8601": "2024-12-14T17:13:07.629450Z",
"url": "https://files.pythonhosted.org/packages/cf/ee/eff3f8e6e37ae55bf3e8ff727ee76b50a4ef85e72682f61ad4f37e2adee5/periodicencryption-1.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-14 17:13:07",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "NilsMT",
"github_project": "periodic-encryption",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "periodicencryption"
}