Crypto
Crypto.b64encode(text)
- Encodes a string with the base64 algorythm.
Parameters
text(string): The string to be encoded with base64.
Return
- (string): The base64 encoded version of the text.
Example
b64encoded = Crypto.b64encode("Hello, World!")print(b64encoded)Result:
SGVsbG8sIFdvcmxkIQ==Crypto.b64decode(text)
- Decodes a base64 encoded string.
Parameters
text(string): The base64 encoded string to be decoded.
Return
- (string): The plaintext version of the base64 encoded text.
Example
text = Crypto.b64decode("SGVsbG8sIFdvcmxkIQ==")print(text)Result:
Hello, World!Crypto.sha256(text)
- Hashes a string with sha256.
Parameters
text(string): The base64 encoded string to be decoded.
Return
- (string): The sha256 version of the string.
Example
hash = Crypto.sha256("S3cure!")print(hash)Result:
7a913a796142c0c12e7e8a23658e92e7e8d0f7050e09766b3195825fc582e827Crypto.aes128(choice, password, text)
- Encrypts or decrypts a string with aes128.
Parameters
choice(string): Choose between ‘encrypt’ or ‘decrypt’.encrypt: Encrypts the string.decrypt: Decrypts the string.
password(string): The password used to encrypt the string with.text(string): The string to be encrypted or decrypted.
Return
- (string): The aes128 encrypted or decrypted version of the string.
Example
text = "Nuclear launch codes: 23981734, 72910394, 91374013"password = "s3cure"ciphertext = Crypto.aes128("encrypt", password, text)decrypted = Crypto.aes128("decrypt", password, ciphertext)print(ciphertext)print(decrypted)Result:
TUUJatDGd8ovL4voHxFLe9xJtcHxpheDjeGSDvUjKoEptnAC02j97b0Zy2CL17qHOLXX0OHOvWdvJ1vT5A313Arzj6D4Nuclear launch codes: 23981734, 72910394, 91374013