(length)
| 1 | const { randomBytes } = require("crypto"); |
| 2 | |
| 3 | function 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 | |
| 11 | exports.safeRandomString = safeRandomString; |
no outgoing calls
no test coverage detected