Skip to main content

stoken

substitute-token

简体中文 | English docs

A code desensitization tool, which can substitute tokens (and other sensitive information) in your code.


Quick start

  1. Run: pip install stoken

  2. 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
  1. Here is demonstration code file, with the suffix .py:
# demo.py
token = "qwertyuiop123456789"
password = "poiuytrewq987654321"
print(f"{token=}, {password=}")
  1. Run stoken --mode hide, or run directly stoken with the default parameter --mode auto, the tokens will be substituted.
# demo.py
token = "#{{SECRET_TOKEN}}#"
password = "#{{MY_PASSWORD}}#"
print(f"{token=}, {password=}")
  1. Run stoken --mode restore, or run directly stoken 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.

Metadata

Release files for stoken 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stoken 0.2.2
File Size Uploaded Provenance Actions
stoken-0.2.2.tar.gz 16.4 kB Without provenance Details for stoken-0.2.2.tar.gz

Release files / stoken-0.2.2.tar.gz

Download URL stoken-0.2.2.tar.gz
Size 16.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5a424e80af14a9880ecbd67b43b7c7ebbc43fed02f0ac659bde6cc17b71beed8
BLAKE2b-256 checksum
How to use checksums
7fcfa1025e628bed4f52626e1ecff211b0d7e08986f00eb1803dba3f426bc888
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.7

Security for stoken 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page