|
@ -123,7 +123,7 @@ public class LoginGUI extends JFrame implements ActionListener { |
|
|
if (userList != null) { |
|
|
if (userList != null) { |
|
|
for (CreateUser user : userList) { |
|
|
for (CreateUser user : userList) { |
|
|
if (user.getUserName().equals(username)) { |
|
|
if (user.getUserName().equals(username)) { |
|
|
String hashedPassword = hashPassword(password); |
|
|
|
|
|
|
|
|
String hashedPassword = PasswordHasher.hashPassword(password); |
|
|
if (user.getPassword().equals(hashedPassword)) { |
|
|
if (user.getPassword().equals(hashedPassword)) { |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
@ -133,25 +133,6 @@ public class LoginGUI extends JFrame implements ActionListener { |
|
|
return false; |
|
|
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 { |
|
|
private class EnterKeyListener implements KeyListener { |
|
|
@Override |
|
|
@Override |
|
|
public void keyTyped(KeyEvent e) {} |
|
|
public void keyTyped(KeyEvent e) {} |
|
|