-2

I'm making a small password manager for personal use. I was wondering if i could create an encrypted string with a password. this password will be a string or byte. i also looked at the Fernet class from cryptography but I want to be abel to remember the password so that is no option. I also want to decrypt it.

Rik Smits
  • 31
  • 7

2 Answers2

0

Check out https://pypi.org/project/pycrypto/

Example from the site (which seems to be what you need):

>>> from Crypto.Cipher import AES
>>> obj = AES.new('This is a key123', AES.MODE_CBC, 'This is an IV456')
>>> message = "The answer is no"
>>> ciphertext = obj.encrypt(message)
>>> ciphertext
'\xd6\x83\x8dd!VT\x92\xaa`A\x05\xe0\x9b\x8b\xf1'
>>> obj2 = AES.new('This is a key123', AES.MODE_CBC, 'This is an IV456')
>>> obj2.decrypt(ciphertext)
'The answer is no'

0

Give a try with this tiny python module acting as a wrapper to cryptography

pip install pyeasyencrypt

Example of code:

import logging, os
# pip install pyeasyencrypt
from pyeasyencrypt.pyeasyencrypt import encrypt_string, decrypt_string

level = os.getenv("LOGGER", "INFO")
logging.basicConfig(level=level)
logger = logging.getLogger(__name__)

def main():
    logger.info("Example")
    clear_string = 'stringA'
    password = "my password"
    encrypted_string = encrypt_string(clear_string, password)
    decrypted_string = decrypt_string(encrypted_string, password)
    logger.info(f"clear_string={clear_string} decrypted_string={decrypt_string} password={password}  encrypted_string={encrypted_string}")
    logger.debug("Done")

if __name__ == '__main__':
    main()

For more details of the source code check out at github https://github.com/redcorjo/pyeasyencrypt

https://pypi.org/project/pyeasyencrypt/