(size: number)
| 4 | |
| 5 | // Returns a new random hex string of the given even size. |
| 6 | export function randomHexString(size: number): string { |
| 7 | if (size === 0) { |
| 8 | throw new Error('Zero-length randomHexString is useless.'); |
| 9 | } |
| 10 | if (size % 2 !== 0) { |
| 11 | throw new Error('randomHexString size must be divisible by 2.'); |
| 12 | } |
| 13 | return randomBytes(size / 2).toString('hex'); |
| 14 | } |
| 15 | |
| 16 | // Returns a new random alphanumeric string of the given size. |
| 17 | // |
no test coverage detected