Crypto_sim/crypto-sim is a Python library for dealing with cryptography(secure encryption and decryption).
Use the package manager pip to install crypto-sim.
pip install crypto-sim
from crypto_sim import crypto
crypto.generate_key()
>>> b'KFH1RhgN_JydLaZzAv6QbpQzsET1SQLjjaFz9dR2-To=' #A key will be returned
from crypto_sim import crypto
crypto.save_and_create_key() #A key will be automatically generate and saved
from crypto_sim import crypto
crypto.get_key()
Note:- this only works when the save_and_create_key() is used
from crypto_sim import
key=crypto.generate_key()
plain_message="hi"
encrypted=crypto.encrypt(plain_message,key)
print(encrypted)
Output:-
>>> b'gAAAAABe7uOq4PYOSe9usicMgivc0oVJWaWBzBQmbZbICgrG7TfbdxK8bIuXqttaw-rnScJBGd2RUxgSaC3_CTK0NwbJS_THJA=='
First, we will execute the above code and then we will get the key and the encrypted message
After that,
# This full code is after the above code
decrypted=crypto.decrypt(encryption,key)
print(decrypted)
plain_message==decrypted
Output:-
>>> hi
>>> True