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:
--mode [auto|hide|restore|debug] The mode of operation. Default: auto.
-e, --encoding TEXT The encoding used to decode the file.
-p, --variable-prefix TEXT The prefix of variable placeholder.
-s, --variable-suffix TEXT The suffix of variable placeholder.
--debug In debug mode, `stoken` won't modify files,
only detect tokens.
--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.1.0.tar.gz
(15.7 kB
view details)
Built Distribution
stoken-0.1.0-py3.9.egg
(6.8 kB
view details)
File details
Details for the file stoken-0.1.0.tar.gz
.
File metadata
- Download URL: stoken-0.1.0.tar.gz
- Upload date:
- Size: 15.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 951e732c36bb1bc273a10eefbcb371ed6ed0efbcdc3b34fdc1b40284658b1cbb |
|
MD5 | bc9f681ff8f5724e7ac1afee05e19a1b |
|
BLAKE2b-256 | f0c97d4e2d1c97f2595e3baecd19b7ac17ef76270d881ad98e4ab88cef8c96a5 |
Provenance
File details
Details for the file stoken-0.1.0-py3.9.egg
.
File metadata
- Download URL: stoken-0.1.0-py3.9.egg
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4fbde8023a709cee24c14b3862162fd6c63f36972ab55d9e5f7deda4783cd00e |
|
MD5 | d5b9cdc7cb73c1355d5956f1f02a854d |
|
BLAKE2b-256 | 110e1ef8d2d7c3aab8782e9bf64c7b133e3ee404f26deac3d1007bc3c584e4ea |