A code desensitization tool, which can substitute tokens (and other sensitive information) in your code.
Project description
stoken
substitute-token
A code desensitization tool, which can substitute tokens (and other sensitive information) in your code.
Quick start
-
Run:
pip install stoken
-
In the root directory of your project, create
stoken.yaml
and edit it with syntax of yaml.suffix
: the suffix of the files you want to detect. Don't forget there's a.
before it.token
: the sensitive data you want to substitute.
suffix:
- .py
- .js
token:
SECRET_TOKEN: qwertyuiop123456789
MY_PASSWORD: poiuytrewq987654321
- Here is demonstration code file, with the suffix
.py
:
# demo.py
token = "qwertyuiop123456789"
password = "poiuytrewq987654321"
print(f"{token=}, {password=}")
- Run
stoken --mode hide
, or run directlystoken
with the default parameter--mode auto
, the tokens will be substituted.
# demo.py
token = "#{{SECRET_TOKEN}}#"
password = "#{{MY_PASSWORD}}#"
print(f"{token=}, {password=}")
- Run
stoken --mode restore
, or run directlystoken
with the default parameter--mode auto
, the tokens will be restored.
API
stoken --help
options | description |
---|---|
--mode | The mode of operation. Default: auto |
-e | --encoding | The encoding used to decode the file. Default: utf-8 |
-p | --variable-prefix | The prefix of variable placeholder. Default: #{{ |
-s | --variable-suffix | The suffix of variable placeholder. Default: }}# |
--debug | Activate this option to enter debug mode, as result, stoken won't modify files, only detect tokens. |
--no-git | By default, the program will detect if there is a git directory, and if so, it will ignore the files in .gitignore . Activate this option to detect all the files. |
--help | Show this message and exit. |
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
stoken-0.2.2.tar.gz
(16.4 kB
view details)
File details
Details for the file stoken-0.2.2.tar.gz
.
File metadata
- Download URL: stoken-0.2.2.tar.gz
- Upload date:
- Size: 16.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a424e80af14a9880ecbd67b43b7c7ebbc43fed02f0ac659bde6cc17b71beed8 |
|
MD5 | 2b439b295dcdb2adf56b7d6dfe6a819c |
|
BLAKE2b-256 | 7fcfa1025e628bed4f52626e1ecff211b0d7e08986f00eb1803dba3f426bc888 |