diff --git a/src/main/java/CreateUser.java b/src/main/java/CreateUser.java index 01085c9..e3ce511 100644 --- a/src/main/java/CreateUser.java +++ b/src/main/java/CreateUser.java @@ -26,7 +26,7 @@ class CreateUser { public CreateUser(String id, String name, String password, String birthday, String firstName, String surname) { this.id = id; this.userName = name; - this.password = PasswordHasher.hashPassword(password);; + this.password = PasswordHasher.hashPassword(password); this.birthday = birthday; this.firstName = firstName; this.surname = surname; diff --git a/src/main/java/LoginGUI.java b/src/main/java/LoginGUI.java index 1c4ef8f..c1f61ec 100644 --- a/src/main/java/LoginGUI.java +++ b/src/main/java/LoginGUI.java @@ -123,7 +123,7 @@ public class LoginGUI extends JFrame implements ActionListener { if (userList != null) { for (CreateUser user : userList) { if (user.getUserName().equals(username)) { - String hashedPassword = hashPassword(password); + String hashedPassword = PasswordHasher.hashPassword(password); if (user.getPassword().equals(hashedPassword)) { return true; } @@ -133,25 +133,6 @@ public class LoginGUI extends JFrame implements ActionListener { return false; } - private String hashPassword(String password) { - try { - MessageDigest digest = MessageDigest.getInstance("SHA-256"); - byte[] hash = digest.digest(password.getBytes()); - StringBuilder hexString = new StringBuilder(); - for (byte b : hash) { - String hex = Integer.toHexString(0xff & b); - if (hex.length() == 1) { - hexString.append('0'); - } - hexString.append(hex); - } - return hexString.toString(); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - return null; - } - } - private class EnterKeyListener implements KeyListener { @Override public void keyTyped(KeyEvent e) {} diff --git a/user.json b/user.json index 0637a08..cd6dd0d 100644 --- a/user.json +++ b/user.json @@ -1 +1,11 @@ -[] \ No newline at end of file +[ + { + "id": "c99b1061-13b7-4fa8-b1ac-814e07db3ef4", + "userName": "Test", + "password": "8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92", + "birthday": "", + "firstName": "", + "surname": "", + "stayLoggedIn": false + } +] \ No newline at end of file