Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix BASE64 Problems with SUN #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/net/launcher/utils/ThreadUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;

import org.apache.commons.codec.binary.Base64;

public class ThreadUtils {
public static Thread serverPollThread;
static String d = y.e() + "1234";
Expand Down Expand Up @@ -399,7 +401,7 @@ public void run() {
String bytes64 = null;
try {
bytes = getBytesFromFile(file);
bytes64 = new String(new sun.misc.BASE64Encoder().encode(bytes));
bytes64 = new String(Base64.encodeBase64(bytes));
} catch (Exception e1) {
e1.printStackTrace();
}
Expand Down Expand Up @@ -763,7 +765,7 @@ static String encrypt(String input, String key) {
} catch (Exception e) {
BaseUtils.sendErr("Ключ должен быть 16 символов");
}
return new String(Base64.getEncoder().encode(crypted));
return new String(Base64.encodeBase64(crypted));
}

static String decrypt(String input, String key) {
Expand All @@ -772,12 +774,12 @@ static String decrypt(String input, String key) {
SecretKeySpec skey = new SecretKeySpec(key.getBytes(), "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, skey);
output = cipher.doFinal(Base64.getDecoder().decode(input));
output = cipher.doFinal(Base64.decodeBase64(input));
} catch (Exception e) {
BaseUtils.sendErr(
"Ключ шифрование не совпадает или больше 16 символов, или полученна ошибка от launcher.php");
BaseUtils.sendErr("Проверьте настройку  в Settings.java или connect.php");
}
return new String(output);
}
}
}