Advertisement
Guest User

Untitled

a guest
Jun 20th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. package uk.co.hexeption.api.io;
  2.  
  3. import java.io.UnsupportedEncodingException;
  4. import java.security.MessageDigest;
  5. import java.security.NoSuchAlgorithmException;
  6. import java.util.Random;
  7.  
  8. /**
  9. * Created by Hexeption on 16/01/2017.
  10. */
  11. public final class HWID {
  12.  
  13. /**
  14. * Gives a HWID I.E (350-30a-3ae-30e-304-3d6-37d-359-371-3e0-3d8-3e1-369-3b2-34a-314) - Hexeption
  15. * @return
  16. * @throws NoSuchAlgorithmException
  17. * @throws UnsupportedEncodingException
  18. */
  19. public static String getHWID() throws NoSuchAlgorithmException, UnsupportedEncodingException {
  20.  
  21. String s = "";
  22. final String main = System.getenv("PROCESSOR_IDENTIFIER") + System.getenv("COMPUTERNAME") + System.getProperty("user.name").trim();
  23. final byte[] bytes = main.getBytes("UTF-8");
  24. final MessageDigest messageDigest = MessageDigest.getInstance("MD5");
  25. final byte[] md5 = messageDigest.digest(bytes);
  26. int i = 0;
  27. for (final byte b : md5) {
  28. s += Integer.toHexString((b & 0xFF) | 0x300).substring(0, 3);
  29. if (i != md5.length - 1) {
  30. s += "-";
  31. }
  32. i++;
  33. }
  34. return s;
  35. }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement