INNER CODE UNIT · TypeScript

genRandomOtpCode

pagopa/io-app · apps/dev-api-server/src/features/cgn/utils/index.ts:12

export function genRandomOtpCode(length: number = BONUSCODE_LENGTH): OtpCode {
  const randomBuffer = randomBytes(length);
  const code = [...Array.from(randomBuffer)]
    .map(b => ALPHABET[b % ALPHABET_LEN])
    .join("");
  return code as OtpCode;
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…