Python implementation of Window's Securestring forked from aznashwan/py-securestring
Project description
This package serves as a mean to save passwords securely in Windows 10 machines.
It uses PowerShell's SecureString
function and objects.
Installation
You install this package simply from PyPI.org by:
pip install pysecstring
You could pip install directly from this github repository - which is the development repository.
Also, you could install it by git cloning this repository and poetry install
it.
git clone https://github.com/gwangjinkim/pysecstring.git
cd pysecstring
poetry install
Usage
The functions encrypt()
and decrypt()
serve as pure Python equivalents of the ConvertTo-SecureString
(or Read-Host -AsSecureString
) and the ConvertFrom-SecureString
functions in PowerShell.
set_credentials()
asks you for entering your username and password (starred input), which will store your credentials in two separate files in form of SecureStrings
(hexed binary - with a seed generated inside your computer).
get_credentials()
reads these stored files and packs the credentials into a CredentialObject
also known from PowerShell (but a Python equivalent version of it).
When probing for .password
and .username
properties from this credential, property-methods decrypt them immediately into plain text (but they are nowhere stored in plain text form - to enhance safety).
At any time point and place in your script, username and password are stored only in their encrypted form.
set_credentials()
and get_credentials()
work only when run on the same machine. Because different machines use different salts for encryption and decryption.
# save your credentials in the files `.\.user` and `.\.pass` in your machine:
username_file = '.\.user'
pass_file = '.\.pass'
set_credentials(username_file, pass_file)
# then PowerShell asks you for input of username and pass
# and these are stored in the username and pass files in an encrypted form - SecureString
# reads-in the SecureStrings and return them as one credential object
co = get_credentials(username_file, pass_file)
# these credential object you can probe using property methods to get the decrypted plain text forms on the fly
co.username # returns decrypted username
co.password # returns decrypted password
# the decryption happens when the properties are called (property objects)
This repository started as a fork of aznashwan/py-securestring
.
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
Built Distribution
Hashes for pysecstring-0.1.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6e0add8696ac9d48766da68710729a71b06d3063be746d1c9abf90682c15ce4 |
|
MD5 | 1dbd1b7b6d75f83824febe4f35eaa07c |
|
BLAKE2b-256 | 17df42760781bb1a7e9886b695c52f58b087fa8c8eae7a97b70b8a722bf27e43 |