Advertisement
Guest User

Untitled

a guest
Jun 1st, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. public boolean checkAccount(String enteredUser, String enteredPass) {
  2. try {
  3. Statement stmt = MySQL.conn.createStatement();
  4. ResultSet rs;
  5. rs = stmt
  6. .executeQuery("SELECT * FROM mybb_users WHERE username = '"
  7. + enteredUser + "'");
  8. while (rs.next()) {
  9. String password = rs.getString("password");
  10. String salt = rs.getString("salt");
  11. String myInput = passHash(enteredPass, salt);
  12. if (myInput.equalsIgnoreCase(password)) {
  13. return true;
  14. } else {
  15. return false;
  16. }
  17.  
  18. }
  19. stmt.close();
  20. } catch (Exception e) {
  21. System.err.println(e.getMessage());
  22. }
  23. return false;
  24. }
  25.  
  26. public String passHash(String in, String salt) {
  27. String saltM = new MD5(salt).compute();
  28. String passM = new MD5(in).compute();
  29. return new MD5(saltM + passM).compute();
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement