custom_encryption
Description: This module provides encryption and decryption of text using AES algorithm. User can encrypt and decrypt text using a specified key.
CustomEncryption
A class that provides static methods to encrypt and decrypt text using an AES algorithm in GCM mode.
Methods:
Name | Description |
---|---|
- custom_encrypt |
Encrypts the given text using a specified key. |
- custom_decrypt |
Decrypts the given encrypted text using |
Usage
encrypted = CustomEncryption.custom_encrypt("Hello, World!", b"example!KeyLen24or16or32") decrypted = CustomEncryption.custom_decrypt(encrypted, b"example!KeyLen24or16or32")
Source code in libs\cafex_core\src\cafex_core\utils\custom_encryption.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
custom_decrypt(cipher_text, secret_key)
staticmethod
Decrypts the given encrypted text using the specified key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cipher_text
|
str
|
The text to be decrypted. |
required |
secret_key
|
bytes
|
The decryption key. The decryption key ex: |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
The decrypted text. |
Example
decrypted = CustomEncryption.custom_decrypt("encrypted", b"example!KeyLen24or16or32")
Notes: Size of a key (in bytes) key_size = (16, 24, 32)
Source code in libs\cafex_core\src\cafex_core\utils\custom_encryption.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
custom_encrypt(plain_text, secret_key)
staticmethod
Encrypts the given text using a specified key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
plain_text
|
str
|
The text to be encrypted. |
required |
secret_key
|
bytes
|
The encryption key ex: b"example!KeyLen24or16or32" |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
The encrypted text. |
Example
encrypted = CustomEncryption.custom_encrypt("Hello, World!", b"example!KeyLen24or16or32")
Notes: Size of a key (in bytes) key_size = (16, 24, 32)
Source code in libs\cafex_core\src\cafex_core\utils\custom_encryption.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|