GithubHelp home page GithubHelp logo

dch42 / cfg_crypt Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 28 KB

Module to create, encrypt, and decrypt a small config file for login info.

License: GNU General Public License v3.0

Python 91.45% Makefile 8.55%

cfg_crypt's Introduction

cfg_crypt

Module to create, encrypt, and decrypt a small config file for email/pw combos.

Attempts to mitigate allowing unencrypted sensitive data to live on the HDD, as even environment variables are trivially accessed on a comprimised device. Keys and encrypted config files are stored in hidden directories in the user's home directory, named according to the script that called the functions.

/Users/user/.cfg_crypt/
├── .cfg_crypt.key
└── .cfg_crypt_cfg

⚠️ Although data is stored outside of project directories, the risk of keys being pushed or otherwise accessed is still nonzero and caution should be taken.

Usage

Can be used as a stand-alone script, or imported as a module to larger scripts for more versatility:

import cfg_crypt as cc

For now, scripts importing as a module should declare their name:

script_name = "Script"

Functions

cc.make_hidden_dir(script_name), creates hidden directory in user $HOME and returns directory path

cc.gen_key(path, script_name), generates a fernet encryption key:

Generating encryption key...
==> Key generated at '/Users/user/.script_name/.script_name.key'

cc.gen_cfg(path, script_name), stores email + pw info in a string in memory:

Generating config file...
Please enter your login email: [email protected]
Please enter your login password: 

cc.encrypt_cfg(cfg, key, path, script_name), encrypts cfg string using fernet key and writes encrypted file to disk:

Encrypting config file...
Encryption complete.
==> Encrypted file saved at '/Users/user/.script_name/.script_name_cfg'

cc.read_key(path, script_name), reads encryption key from disk

cc.decrypt_cfg(key, path, script_name), decrypts encrypted cfg data and returns as a dictionary

cfg={'EMAIL': '[email protected]', 'PW': 'test'}
cfg['EMAIL']='[email protected]'
cfg['PW']='test'

cfg_crypt's People

Contributors

dch42 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.