fix(auth): ganti Math.random() dengan crypto.randomInt untuk OTP
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>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { randomInt } from "crypto";
|
||||
|
||||
export function randomOTP() {
|
||||
const random = Math.floor(Math.random() * (9000 - 1000 )) + 1000
|
||||
return random;
|
||||
return randomInt(1000, 10000);
|
||||
}
|
||||
Reference in New Issue
Block a user