This project aims to create a Java Swing-based graphical user interface (GUI) for a login and registration system. The application will allow users to register with a username, password, and email address, and subsequently log in using their credentials. The system will enforce password strength, validate email addresses using regular expressions, and securely store user credentials by hashing passwords with SHA-256. User data will be stored in files.
-
User Registration and Login:
- Users can register by providing a username, password, and email.
- Users can log in using their username and password.
-
Password Strength Validation:
- Password strength will be evaluated based on the following criteria:
- Contains lowercase or uppercase characters or numbers.
- Contains both lowercase and uppercase characters.
- Contains uppercase, lowercase, and numbers.
- Contains special characters (@, -, _ , .).
- Longer than 8 characters.
- Password strength will be evaluated based on the following criteria:
-
Email Validation:
- Email addresses will be validated using regular expressions to ensure they are in a valid format.
-
Password Hashing:
- Passwords will be hashed using SHA-256 before storing.
- The login process will involve hashing the entered password and comparing it to the stored hash.
-
Data Storage:
- User data will be stored in files on the filesystem.
-
Graphical User Interface:
- Developed using Java Swing for a robust and user-friendly interface.
srcMain.java- Entry point of the application.LoginGUI.java- Handles the GUI components and events.User.java- Represents a user and contains methods for hashing and validating passwords.UserStore.java- Handles storing and retrieving user data from files.PasswordUtils.java- Contains utility methods for password strength evaluation and hashing.EmailValidator.java- Contains method for validating email addresses using regex.
The password strength is evaluated based on the following criteria:
- Level 1: Contains lowercase or uppercase characters or numbers.
- Level 2: Contains both lowercase and uppercase characters.
- Level 3: Contains uppercase, lowercase, and numbers.
- Level 4: Contains special characters (@, -, _ , .).
- Level 5: Longer than 8 characters.
Email addresses are validated using a regular expression to ensure they are in a standard format.
Passwords are hashed using the SHA-256 algorithm. Here’s a brief explanation of how hashing and login work:
- Hashing: When a user registers, their password is hashed using SHA-256 before being stored.
- Storing: The hashed password, along with the username and email, is stored in a file.
- Login: During login, the entered password is hashed, and the resulting hash is compared to the stored hash. If they match, the login is successful.
The GUI will be designed using Java Swing with the following components:
- Login Panel: Username field, password field, and login button.
- Registration Panel: Username field, password field, email field, and register button.
- Message Labels: For displaying success or error messages.
User data will be stored in a text file (users.txt) with each line containing a user's username, hashed password, and email, separated by commas.
Example:
username1,hashedpassword1,email1@example.com
username2,hashedpassword2,email2@example.com
This project is a Java Swing-based application that provides a graphical user interface for user login and registration. The application includes password strength validation, email validation, password hashing using SHA-256, and file-based user data storage.
- User registration with username, password, and email.
- User login with username and password.
- Password strength evaluation.
- Email format validation.
- Secure password storage using SHA-256 hashing.
- User-friendly GUI developed with Java Swing.
-
Register a new user:
- Open the application.
- Navigate to the registration panel.
- Enter a username, password, and email.
- Click the "Register" button.
-
Login:
- Open the application.
- Navigate to the login panel.
- Enter your username and password.
- Click the "Login" button.