dump data: corelibs_dump_data stack trace: corelibs_stack_trace profiling, timing, etc: corelibs_debug
35 lines
915 B
Python
35 lines
915 B
Python
#!/usr/bin/env python3
|
|
|
|
"""
|
|
Symmetric encryption test
|
|
"""
|
|
|
|
import json
|
|
from corelibs_dump_data.dump_data import dump_data
|
|
from corelibs.encryption_handling.symmetric_encryption import SymmetricEncryption
|
|
|
|
|
|
def main() -> None:
|
|
"""
|
|
Comment
|
|
"""
|
|
password = "strongpassword"
|
|
se = SymmetricEncryption(password)
|
|
|
|
plaintext = "Hello, World!"
|
|
ciphertext = se.encrypt_with_metadata_return_str(plaintext)
|
|
decrypted = se.decrypt_with_metadata(ciphertext)
|
|
print(f"Encrypted: {dump_data(json.loads(ciphertext))}")
|
|
print(f"Input: {plaintext} -> {decrypted}")
|
|
|
|
static_ciphertext = SymmetricEncryption.encrypt_data(plaintext, password)
|
|
decrypted = SymmetricEncryption.decrypt_data(static_ciphertext, password)
|
|
print(f"Static Encrypted: {dump_data(json.loads(static_ciphertext))}")
|
|
print(f"Input: {plaintext} -> {decrypted}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|
|
# __END__
|