import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
public class AESUtil {
public static String encrypt(String data, String key) {
try {
return doAES(data, key, 1);
} catch (Exception var3) {
return null;
}
}
public static String decrypt(String data, String key) throws Exception {
return doAES(data, key, 2);
}
private static String doAES(String data, String key, int mode) throws Exception {
boolean encrypt = mode == 1;
byte[] content;
if (encrypt) {
content = data.getBytes("UTF-8");
} else {
content = parseHexStr2Byte(data);
}
KeyGenerator kgen = KeyGenerator.getInstance("AES");
SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG");
secureRandom.setSeed(key.getBytes());
kgen.init(128, secureRandom);
SecretKey secretKey = kgen.generateKey();
byte[] enCodeFormat = secretKey.getEncoded();
SecretKeySpec keySpec = new SecretKeySpec(enCodeFormat, "AES");
Cipher cipher = Cipher.getInstance("AES");
cipher.init(mode, keySpec);
byte[] result = cipher.doFinal(content);
return encrypt ? parseByte2HexStr(result) : new String(result, "UTF-8");
}
public static String parseByte2HexStr(byte[] buf) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < buf.length; ++i) {
String hex = Integer.toHexString(buf & 255);
if (hex.length() == 1) {
hex = '0' + hex;
}
sb.append(hex.toUpperCase());
}
return sb.toString();
}
public static byte[] parseHexStr2Byte(String hexStr) {
if (hexStr.length() < 1) {
return null;
} else {
byte[] result = new byte;
for (int i = 0; i < hexStr.length() / 2; ++i) {
int high = Integer.parseInt(hexStr.substring(i * 2, i * 2 + 1), 16);
int low = Integer.parseInt(hexStr.substring(i * 2 + 1, i * 2 + 2), 16);
result = (byte) (high * 16 + low);
}
return result;
}
}
public static void main(String[] args) throws Exception {
String key = "Empathic_202210";
// 解密
System.out.println(AESUtil.decrypt("4FCE3841E803F1D63A2216C238CE7495", key));
// 加密
System.out.println(AESUtil.encrypt("111.229.213.189", key));
}
}
crack007 发表于 2024-2-18 13:21
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator; ...
ip加密解密的java代码 关于天策符的问题有没有老哥能解决啊? 帮修改后台+q200729241,加前备注后台 感谢分享!楼主威武,新年发大财! 后台是不是还需要改哪里的IP?按照教程改的后台用不了 IP是加密过的 200729241 发表于 2024-2-18 18:15
帮修改后台+q200729241,加前备注后台
要钱吗? crack007 发表于 2024-2-18 13:22
ip加密解密的java代码
怎么用 啊 crack007 发表于 2024-2-18 13:21
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator; ...
大佬这个怎么用啊 来个说明啊 qq07436501 发表于 2024-2-18 09:40
虚拟机搭建玩的就不要试了 虚拟机IP无效 只能用服务器的IP地址也就是说要公网IP才可以
我就是虚拟机搭建的,只要把 t-groups表groups ip 把里面加密大写一串
4FCE3841E803F1D63A2216C238CE7495
直接改成你的IP 不用加密只是不过后台用不了 感谢分享 谢谢分享 wangle12312 发表于 2024-2-18 14:16
关于天策符的问题有没有老哥能解决啊?
天策本来就能用啊,转生后升级就行了,数据库修改的就别说了 : 大佬们求教添加好友系统跟外观功能怎么弄啊 为什么链接服务器失败啊!! 模拟器里能玩,但是手机上安卓13安装不了,有大佬知道怎么办吗? rose521rain 发表于 2024-3-27 08:42
模拟器里能玩,但是手机上安卓13安装不了,有大佬知道怎么办吗?
APP需要签名才可以安装 很好。下次试试。看。 ::
页:
1
[2]