(length: number)
| 1 | import { randomBytes } from "crypto"; |
| 2 | |
| 3 | export function generateRandomString(length: number): string { |
| 4 | const charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; |
| 5 | const randomBytesArray = randomBytes(length); |
| 6 | let result = ""; |
| 7 | |
| 8 | for (let i = 0; i < length; i++) { |
| 9 | const randomIndex = randomBytesArray[i] % charset.length; |
| 10 | result += charset[randomIndex]; |
| 11 | } |
| 12 | |
| 13 | return result; |
| 14 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…