Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Arthania;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.io.PrintStream;
- import java.net.URL;
- import java.net.URLConnection;
- import java.security.MessageDigest;
- public class LauncherController
- {
- private String salt = "ghfdug456aze45po12vcvcx45";
- private String host = "www.arthania-pvp.fr";
- private Boolean debug = Boolean.valueOf(false);
- public String username;
- public String password;
- public LauncherController(String username, String password)
- {
- this.username = username;
- this.password = password;
- }
- private String getResultFromAPI()
- {
- StringBuilder a = new StringBuilder();
- try
- {
- URL uri = new URL(
- "http://" + this.host + "/launcher/login/" + this.username + "/" + this.password + "/" + this.salt);
- URLConnection ec = uri.openConnection();
- BufferedReader in = new BufferedReader(new InputStreamReader(ec.getInputStream(), "UTF-8"));
- String inputLine;
- while ((inputLine = in.readLine()) != null)
- {
- String inputLine;
- a.append(inputLine);
- }
- in.close();
- if (this.debug.booleanValue()) {
- System.out.println("[LauncherController] Value : " + a.toString() + " for the couple username/password : " +
- this.username + "/" + this.password + " and salt : " + this.salt);
- }
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- return a.toString();
- }
- public boolean checkPlayerAccount()
- {
- String result = getResultFromAPI();
- if (result.equals("true")) {
- return true;
- }
- return false;
- }
- public static String sha256(String base)
- {
- try
- {
- MessageDigest digest = MessageDigest.getInstance("SHA-256");
- byte[] hash = digest.digest(base.getBytes("UTF-8"));
- StringBuffer hexString = new StringBuffer();
- for (int i = 0; i < hash.length; i++)
- {
- String hex = Integer.toHexString(0xFF & hash[i]);
- if (hex.length() == 1) {
- hexString.append('0');
- }
- hexString.append(hex);
- }
- return hexString.toString();
- }
- catch (Exception ex)
- {
- throw new RuntimeException(ex);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement