Feedback Needed on My First Java Password Tool

0
1
Asked By CodeLover22 On

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

Answered By JavaNinja99 On

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!

CodeLover22 -

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

Answered By CleverCoder77 On

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.

CodeLover22 -

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!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.