Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package BlackWhite;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.net.URL;
- import java.net.URLConnection;
- import java.nio.charset.StandardCharsets;
- import java.security.MessageDigest;
- public class LauncherController {
- private String salt = "....";
- private String host = "www.arthania-pvp.fr";
- private Boolean debug = true;
- 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;
- ec = uri.openConnection();
- BufferedReader in = new BufferedReader(new InputStreamReader( ec.getInputStream(), "UTF-8"));
- String inputLine;
- while ((inputLine = in.readLine()) != null){
- a.append(inputLine);
- }
- in.close();
- if(debug){
- 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 = this.getResultFromAPI();
- if(result.equals("true")){
- return true;
- }else{
- 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