|
本帖最后由 不敗的米 于 2018-8-21 11:29 編輯
附送5位和C6位算法
package ppma;
import java.security.MessageDigest;
public class pwd {
public static void main(String[] args){
System.out.print(args[0]+"\n"+args[1]+"\n");
System.out.print("5:"+gethashCode(args[0],args[1])+"\n");
String change = mark(args[0],args[1]);
System.out.print("C6:"+gethashCode(change,args[1])+"\n");
return;
}
private static int gethashCode(String mac,String rand){
String build = builder(mac,rand);
String md5 = MD5(build);
return Math.abs(md5.hashCode());
}
private static String mark(String mac,String salt){
char[] char_mac = mac.toCharArray();
char[] char_salt = salt.toCharArray();
int length_mac =char_mac.length;
int length_rand = char_salt.length;
char_mac[length_mac-1]=char_salt[length_rand-1];
int i=0,j=0;
while(i<length_mac&&j<length_rand){
if(char_mac==':') char_mac=char_salt[j++];
i++;
}
return String.copyValueOf(char_mac);
}
private static String builder(String mac,String salt){
return "open_ADB"+salt+"@"+ mac+"ZTE_ENCRYPT";
}
private static String MD5(String s) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] bytes = md.digest(s.getBytes("utf-8"));
return toHex(bytes);
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
private static String toHex(byte[] bytes) {
final char[] HEX_DIGITS = "0123456789ABCDEF".toCharArray();
StringBuilder ret = new StringBuilder(bytes.length * 2);
for (int i=0; i<bytes.length; i++) {
ret.append(HEX_DIGITS[(bytes >> 4) & 0x0f]);
ret.append(HEX_DIGITS[bytes & 0x0f]);
}
return ret.toString();
}
}
|
上一篇: 中興zxv10 b860a V2.1自動(dòng)升級(jí)后無法安裝第三方軟件下一篇: 860AV1.1怎么禁止自動(dòng)升級(jí)
|