The DSH plugin system emphasizes functional modularity. During development, it is often necessary to generate random verification codes, test data, or perform array sampling. Manually implementing random number generation can easily lead to pseudo-randomness or logical vulnerabilities. On the other hand, dsh-random provides secure random number generation based on the Node.js built-in crypto module, as well as array sampling and shuffling capabilities that can be called directly in DSH sessions.
This is a DSH plugin maintained by uckkk. It focuses on providing secure random number generation and array processing tools, helping developers quickly complete tasks such as verification code generation and data sampling.
Core Features¶
The plugin provides three main tools:
random_int: Generates a random integer.random_string: Generates a random string.random_pick: Samples or shuffles an array.
Installation and Enablement¶
- Run the installation command:
dsh plugin add dsh-random
- In the project’s
package.json, locate thedsh.profile.bundlesfield and add"dsh-random".
Typical Usage¶
You can invoke the tools registered by the plugin in a session. For example, to generate a six-digit numeric verification code:
random_string(length=6, charset="digit")
Applicable Scenarios and Precautions¶
- The plugin is implemented using pure Node.js and relies on the
cryptomodule at a lower level, so its security level is relatively high. - Installation means running third-party code on your local machine. Please review the source code before use (available via GitHub).
Summary¶
dsh-random adds basic random number processing capabilities to the DSH plugin ecosystem. If you want to learn more details or submit an Issue, visit the plugin directory or the GitHub repository.