MCPcopy
hub / github.com/graphile/starter / safeRandomString

Function safeRandomString

scripts/lib/random.js:3–9  ·  view source on GitHub ↗
(length)

Source from the content-addressed store, hash-verified

1const { randomBytes } = require("crypto");
2
3function safeRandomString(length) {
4 // Roughly equivalent to shell `openssl rand -base64 30 | tr '+/' '-_'`
5 return randomBytes(length)
6 .toString("base64")
7 .replace(/\+/g, "-")
8 .replace(/\//g, "_");
9}
10
11exports.safeRandomString = safeRandomString;

Callers 2

_setup_utils.jsFile · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected