Skip to main content

Simple Password Protection Solution for Python

Project description

spps-py

Simple Password Protection Solution for Python


Build Status Coverage Status License Version Python versions GitHub issues

The SPPS is a lightweight solution to protect / hide your password or anything else from your code.

Features

Concept

This solution helps one to accidentally publish secrets unintentionally by splitting the secret into an encrypted part and a private key. The private key is kept separately from the rest, in a secure location for the authorized user only.

The private key is randomized for each user on each system and is therefore unique. This means that if someone has the encrypted secret, they can only read it if they also have the private key. You can check this by trying to decrypt the encrypted secret with another user or another system. You will not succeed.

A symmetrical encryption based on the AES-GCM 256 method is used. See also https://en.wikipedia.org/wiki/Galois/Counter_Mode

By default, the private key is stored in a file "/.spps/settings" of the user home folder.

Keep in mind that anyone who has access to the user home or relocation folder also has access to the private key !!!!

Requirements

  • Python version 3
  • Python module pycryptodome

Example

import simple_crypt

encryptedSecret = simple_crypt.encrypt_string("My Secret")
print("My encrypted secret is {}".format(encryptedSecret))

secret = simple_crypt.decrypt_string(encryptedSecret)
print("...and my secret is: {}".format(secret))

How to create an encrypted password

Enter following command in your terminal:

python simple_crypt.py -Secret YourSecret 

Output should look like:

{MLaFzwpNyKJbJSCg4xY5g70WDAKnOhVe3oaaDAGWtH4KXR4=}

As a feature, if the private key does not exist, it will be created automatically when you encrypt a new secret!

How to create a private key

Create a private key in your home folder:

Important Note: Usually you do not need to execute this command unless you want to create a new private key. Remember, secrets already encrypted with the old key cannot be decrypted with the new key!

Enter following command in your terminal:

python simple_crypt.py -CreatePrivateKey

The settings file '~/.spps/settings' in your home folder will look like:

key=5C/Yi6+hbgRwIBhXT9PQGi83EVw2Oe6uttRSl4/kLzc=
relocation=

Alternative, create a private key on a removable device:

Important Note: Remember, secrets already encrypted with the old key cannot be decrypted with the new key!

Enter following command in your terminal:

python simple_crypt.py -CreatePrivateKey -Relocation /Volumes/usb-stick

The settings file '~/.spps/settings' in your home folder will look like:

key=
relocation=/Volumes/usb-stick

...and in the relocation folder look like:

key=5C/Yi6+hbgRwIBhXT9PQGi83EVw2Oe6uttRSl4/kLzc=
relocation=

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spps-py-1.0.0rc1.tar.gz (11.7 kB view details)

Uploaded Source

File details

Details for the file spps-py-1.0.0rc1.tar.gz.

File metadata

  • Download URL: spps-py-1.0.0rc1.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

File hashes

Hashes for spps-py-1.0.0rc1.tar.gz
Algorithm Hash digest
SHA256 42a8473e8ade5c47e52d0559c9817fcde6ed60ecaa9873bf80b4fa19eb8ee4c5
MD5 c9f6c71f5bbb300c3604f182baa3a626
BLAKE2b-256 17b48ec67cf80f14a753aee545b46cb26d848f3d4944409c4eda1dd82add63aa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page