refactor encrypt.py