Advertisement
Guest User

Untitled

a guest
Aug 29th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. package Arthania;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6. import java.io.PrintStream;
  7. import java.net.URL;
  8. import java.net.URLConnection;
  9. import java.security.MessageDigest;
  10.  
  11. public class LauncherController
  12. {
  13. private String salt = "ghfdug456aze45po12vcvcx45";
  14. private String host = "www.arthania-pvp.fr";
  15. private Boolean debug = Boolean.valueOf(false);
  16. public String username;
  17. public String password;
  18.  
  19. public LauncherController(String username, String password)
  20. {
  21. this.username = username;
  22. this.password = password;
  23. }
  24.  
  25. private String getResultFromAPI()
  26. {
  27. StringBuilder a = new StringBuilder();
  28. try
  29. {
  30. URL uri = new URL(
  31. "http://" + this.host + "/launcher/login/" + this.username + "/" + this.password + "/" + this.salt);
  32.  
  33. URLConnection ec = uri.openConnection();
  34. BufferedReader in = new BufferedReader(new InputStreamReader(ec.getInputStream(), "UTF-8"));
  35. String inputLine;
  36. while ((inputLine = in.readLine()) != null)
  37. {
  38. String inputLine;
  39. a.append(inputLine);
  40. }
  41. in.close();
  42. if (this.debug.booleanValue()) {
  43. System.out.println("[LauncherController] Value : " + a.toString() + " for the couple username/password : " +
  44. this.username + "/" + this.password + " and salt : " + this.salt);
  45. }
  46. }
  47. catch (IOException e)
  48. {
  49. e.printStackTrace();
  50. }
  51. return a.toString();
  52. }
  53.  
  54. public boolean checkPlayerAccount()
  55. {
  56. String result = getResultFromAPI();
  57. if (result.equals("true")) {
  58. return true;
  59. }
  60. return false;
  61. }
  62.  
  63. public static String sha256(String base)
  64. {
  65. try
  66. {
  67. MessageDigest digest = MessageDigest.getInstance("SHA-256");
  68. byte[] hash = digest.digest(base.getBytes("UTF-8"));
  69. StringBuffer hexString = new StringBuffer();
  70. for (int i = 0; i < hash.length; i++)
  71. {
  72. String hex = Integer.toHexString(0xFF & hash[i]);
  73. if (hex.length() == 1) {
  74. hexString.append('0');
  75. }
  76. hexString.append(hex);
  77. }
  78. return hexString.toString();
  79. }
  80. catch (Exception ex)
  81. {
  82. throw new RuntimeException(ex);
  83. }
  84. }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement