(evenLength: number)
| 1 | import crypto from 'crypto'; |
| 2 | |
| 3 | export function randomHexString(evenLength: number) { |
| 4 | // We could use "string.substring" to enforce length instead, but not sure how would that affect the randomness. |
| 5 | // Supporting even lengths is enough for now. |
| 6 | if (evenLength % 2 !== 0) { |
| 7 | throw new Error(`Expected length to be even. It was: ${evenLength}`); |
| 8 | } |
| 9 | return crypto.randomBytes(evenLength / 2).toString('hex'); |
| 10 | } |
no outgoing calls
no test coverage detected