Advertisement
Guest User

haslo.java

a guest
Jun 9th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package javafxapplication1;
  7.  
  8. import java.security.MessageDigest;
  9. import java.security.NoSuchAlgorithmException;
  10.  
  11. /**
  12. *
  13. * @author as
  14. */
  15. public class haslo {
  16. public static String haszuj(String pass) throws NoSuchAlgorithmException
  17. {
  18. //String pass = passwordField.getText();
  19. // String username = usernameField.getText();
  20.  
  21. String passwordToHash = pass;
  22. String generatedPassword = null;
  23. MessageDigest md = MessageDigest.getInstance("MD5");
  24. md.update(passwordToHash.getBytes());
  25. byte[] bytes = md.digest();
  26. StringBuilder sb = new StringBuilder();
  27. for(int i=0; i< bytes.length ;i++)
  28. {
  29. sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1));
  30. }
  31. return generatedPassword = sb.toString();
  32. }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement