# Fast Encode - Encoding Made Easy
With Fast Encode you can create **a single object** that automatically uses many encoding types.
## Overview
The Fast Encode module provides the following features:
- A single object that abstracts the following encodings: hex, ascii array, string, bytes, binary and long number.
- Many helper functions that makes changing encoding easier.
## Getting Started
- [ ] First, you need to download it from pip. `pip install fastencode`
- [ ] Then import it to your project.
```python
from fastencode import DataObj as D
```
## Creating and Using an Object
For each encoding type, there is factory function that creates a DataObj object from it.
The factory functions are: `fromHex`, `fromAsc`, `fromStr`, `fromBin`, `fromNum` and `fromBytes`.
```python
plaintext = D.fromStr('secret_msg') # This creates a Data object from a plain string
key = D.fromHex('deadbeef1234')# This creates a Data object from hex
```
Printing the DataObj will show a lot of different encoding at once:
```python
print(f'Output - {plaintext}')
Output - Hex: 7365637265745f6d7367, Ascii: [115, 101, 99, 114, 101, 116, 95, 109, 115, 103],
String: secret_msg, Number: 544942432582961455788903
Binary: 01110011011001010110001101110010011001010111010001011111011011010111001101100111
```
We can get to a specific encoding by using the DataObj fields: `hex`, `asc`, `str`, `bytes`, `bin` and `num`.
```python
print(key.bytes)
# prints b'\xde\xad\xbe\xef\x124'
print(key.asc) # asc is shorthand for ascii, and is a list of integer of the indvidual ascii value of every byte.
# prints [222, 173, 190, 239, 18, 52]
```
## Simple XOR exmaple
Let's take a look at a simple example of XOR-ing 2 strings. We will see how simple it is to do with fastencode.
```python
from fastencode import DataObj as D
plaintext = D.fromStr('secret_msg')
key = D.fromStr('secret_key')
xored_integer_value = plaintext.num ^ key.num # ^ is the python operand for xor
print(xored_integer_value) # prints 398878
ciphertext = D.fromNum(xored_integer_value) # Creating another Data object from the result of the xor
print(ciphertext) # prints Hex: 6161e, ascii: [97, 97, 14], String: aa, Number: 398878 Binary: 011000010110000100001110
```
_Note: In the example the result is only 3-bytes long - as expected - because the first 7 bytes match and are therefore removed._
## Forking and Contribution Ideas
- Creating a genreal function that automatically detects the type of the encoding.
- Adding base64 and base32 encodings.
Raw data
{
"_id": null,
"home_page": "https://github.com/user/reponame",
"name": "fastencode",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "encoding,hex,bytes,binary representation,decoding,ascii,base64",
"author": "ES3",
"author_email": "ourteamscare@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/cd/8f/b70ef55934e6020b8c0594b3e71f49faaca117188bad44ae2d7679977d96/fastencode-1.4.tar.gz",
"platform": null,
"description": "# Fast Encode - Encoding Made Easy\r\n\r\nWith Fast Encode you can create **a single object** that automatically uses many encoding types.\r\n\r\n## Overview\r\n\r\nThe Fast Encode module provides the following features:\r\n\r\n- A single object that abstracts the following encodings: hex, ascii array, string, bytes, binary and long number.\r\n- Many helper functions that makes changing encoding easier.\r\n\r\n## Getting Started\r\n\r\n- [ ] First, you need to download it from pip. `pip install fastencode`\r\n\r\n- [ ] Then import it to your project.\r\n\r\n```python\r\nfrom fastencode import DataObj as D\r\n```\r\n\r\n## Creating and Using an Object\r\n\r\nFor each encoding type, there is factory function that creates a DataObj object from it.\r\nThe factory functions are: `fromHex`, `fromAsc`, `fromStr`, `fromBin`, `fromNum` and `fromBytes`.\r\n\r\n```python\r\nplaintext = D.fromStr('secret_msg') # This creates a Data object from a plain string\r\nkey = D.fromHex('deadbeef1234')# This creates a Data object from hex\r\n```\r\n\r\nPrinting the DataObj will show a lot of different encoding at once:\r\n\r\n```python\r\nprint(f'Output - {plaintext}')\r\n\r\nOutput - Hex: 7365637265745f6d7367, Ascii: [115, 101, 99, 114, 101, 116, 95, 109, 115, 103],\r\n String: secret_msg, Number: 544942432582961455788903\r\n Binary: 01110011011001010110001101110010011001010111010001011111011011010111001101100111\r\n```\r\n\r\nWe can get to a specific encoding by using the DataObj fields: `hex`, `asc`, `str`, `bytes`, `bin` and `num`.\r\n\r\n```python\r\nprint(key.bytes)\r\n# prints b'\\xde\\xad\\xbe\\xef\\x124'\r\n\r\nprint(key.asc) # asc is shorthand for ascii, and is a list of integer of the indvidual ascii value of every byte.\r\n# prints [222, 173, 190, 239, 18, 52]\r\n```\r\n\r\n## Simple XOR exmaple\r\n\r\nLet's take a look at a simple example of XOR-ing 2 strings. We will see how simple it is to do with fastencode.\r\n\r\n```python\r\nfrom fastencode import DataObj as D\r\n\r\nplaintext = D.fromStr('secret_msg')\r\nkey = D.fromStr('secret_key')\r\n\r\nxored_integer_value = plaintext.num ^ key.num # ^ is the python operand for xor\r\nprint(xored_integer_value) # prints 398878\r\n\r\nciphertext = D.fromNum(xored_integer_value) # Creating another Data object from the result of the xor\r\nprint(ciphertext) # prints Hex: 6161e, ascii: [97, 97, 14], String: aa, Number: 398878 Binary: 011000010110000100001110\r\n```\r\n\r\n_Note: In the example the result is only 3-bytes long - as expected - because the first 7 bytes match and are therefore removed._\r\n\r\n## Forking and Contribution Ideas\r\n\r\n- Creating a genreal function that automatically detects the type of the encoding.\r\n- Adding base64 and base32 encodings.\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "An easy way to use different encoding: bytes, hex, ascii array, binary, long, base64",
"version": "1.4",
"project_urls": {
"Download": "https://github.com/elyassaf/Easy-Encoding/archive/refs/tags/v_1.3.tar.gz",
"Homepage": "https://github.com/user/reponame"
},
"split_keywords": [
"encoding",
"hex",
"bytes",
"binary representation",
"decoding",
"ascii",
"base64"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "cd8fb70ef55934e6020b8c0594b3e71f49faaca117188bad44ae2d7679977d96",
"md5": "4a84afa4c78d48331b74ae4bf6bdeee5",
"sha256": "adb58ba11705206622b2e571def1f5765dcdc86444b1f1417c771672bd5869ab"
},
"downloads": -1,
"filename": "fastencode-1.4.tar.gz",
"has_sig": false,
"md5_digest": "4a84afa4c78d48331b74ae4bf6bdeee5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4721,
"upload_time": "2023-05-06T20:16:14",
"upload_time_iso_8601": "2023-05-06T20:16:14.431895Z",
"url": "https://files.pythonhosted.org/packages/cd/8f/b70ef55934e6020b8c0594b3e71f49faaca117188bad44ae2d7679977d96/fastencode-1.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-06 20:16:14",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "user",
"github_project": "reponame",
"github_not_found": true,
"lcname": "fastencode"
}