Math.random() bukan CSPRNG sehingga OTP dapat diprediksi. Diganti dengan crypto.randomInt(1000, 10000) dari Node.js built-in crypto module. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
5 lines
101 B
TypeScript
5 lines
101 B
TypeScript
import { randomInt } from "crypto";
|
|
|
|
export function randomOTP() {
|
|
return randomInt(1000, 10000);
|
|
} |