A Java application that generates a secure 6-digit One-Time Password (OTP) using Java's built-in SecureRandom class.
- Generates a random 6-digit OTP
- Uses
SecureRandomfor cryptographically secure randomness - Guarantees exactly six digits
- Lightweight console application
- Beginner-friendly Java project
The program creates a random number between 100000 and 999999, ensuring every generated OTP contains exactly six digits.
int otp = 100000 + new SecureRandom().nextInt(900000);Compile:
javac OtpGen.javaRun:
java OtpGen