Hey everyone! I'm a freshman in college taking my first Java programming class, and I'm about halfway through the course. To reinforce what I've learned, I've been working on some personal projects. My latest one is a password tool that checks if a password meets certain criteria for validity and rates its strength. I'm also planning to add a feature that generates secure passwords soon.
I'm keen to hear your thoughts! What improvements or enhancements do you think I could make, especially since I'll be learning JavaFX next? Also, can you suggest any other beginner-friendly projects similar to this? Thanks in advance for any feedback!
Here's a snippet of my code:
```java
import java.util.Scanner;
public class PasswordTool {
public static void main(String[] args) {
// Create a scanner
Scanner input = new Scanner(System.in);
boolean valid = false;
while (!valid) {
valid = true;
int score = 0;
String message = "";
// Input from user
System.out.print("Enter a password: ");
String password = input.nextLine();
// Check length, complexity, etc.
}
}
// Validation methods...
}
```
2 Answers
You might want to think about refactoring your validation methods. Using regular expressions could clean up your code significantly. Plus, learning regex is a great skill to have!
Your program is off to a solid start! Just a heads up, for security-related code, it’s better to use cryptographically secure random number generation. The `java.security.SecureRandom` class is great for that. As for the password strength check, it's a bit misleading. If a password is genuinely random and over 12 characters, it's already secure. Just focus on ensuring users avoid common passwords. You might want to check out the [weakpass.com](http://weakpass.com) API for more insights.
That's interesting! I'm currently using the book 'Introduction to Java Programming and Data Structures' by Daniel Liang, so I'm still getting the hang of everything. I'm working on building my understanding before moving on, but I appreciate all the suggestions!

I haven't learned regex yet, but I'll definitely look into it now. Thanks for the tip!