xq.algorithms package
Submodules
xq.algorithms.aes_encryption module
- class xq.algorithms.aes_encryption.AESEncryption(key: bytes, nonce: bytes | None = None)
Bases:
Encryption
AES implimented encryption algorithm
- Parameters:
Encryption (Encryption class) – Inherited Parent class
- decrypt(ciphertext: bytes, verificationTag: bytes | None = None)
decryption method for decrypting a text string
- Parameters:
ciphertext (bytes) – the encrypted text, in bytes
verificationTag (bytes, optional) – verification tag created by encrypt, defaults to None
- Raises:
SDKEncryptionException – SDK decryption error
- Returns:
decrypted string
- Return type:
str
- encrypt(text: str)
encryption method for encrypting a text string
- Parameters:
text (str) – input text to encrypt
- Returns:
ciphertext, nonce, and tag from the cipher encryption
- Return type:
tuple(bytes)
xq.algorithms.encryption module
- class xq.algorithms.encryption.Encryption(key: str)
Bases:
object
parent class for all encryption algorithms
- property key
method property that returns the correct key value used for encryption
- Returns:
key used for encryption
- Return type:
bytes
- shuffle(string: str | None = None)
psudo-randomize a provided string * replicated from jssdk-core
- Parameters:
string (str) – provided string to randomize
- Returns:
randomized string
- Return type:
str
xq.algorithms.otp_encryption module
- class xq.algorithms.otp_encryption.OTPEncryption(key: bytes, max_encryption_chunk_size=2048)
Bases:
Encryption
OTP implimented encryption algorithm
- Parameters:
Encryption (Encryption class) – Inherited Parent class
- decrypt(text: bytes) bytes
decryption method for decrypting a string or file
- Parameters:
text (bytes) – text to decrypt
- Returns:
decrypted text
- Return type:
bytes
- encrypt(msg: bytes)
encryption method for encrypting a bytes-string or bytes-file
- Parameters:
msg (bytes OR FileLike) – message to encrypt
- Raises:
SDKEncryptionException – unsupported message type
- Returns:
encrypted message
- Return type:
bytes