//java中的Byte范围是 -128~127,不知道怎么转成无符号型
//所以绕了弯路 ( 即这一段: if (x<0) x = 256+x )
public class Test{
public static void main(String[] args){
/*
String s1 = new String("abc汉字123"
;
System.out.println("Len(s1) = "
+ s1.getBytes().length);
*/
int x =0;
int n2 = 1 ;
int n1 = 8892636;
String s1 = new String("AB测试00500100291C"
;
String s2 = new String("QW汉字TYUIO7"
;
String s4 = new String(""
;
String s5 = new String(""
;
String s6 = new String(""
;
String zjs = new String("052"
;
System.out.println("s1 = "
+ s1);
System.out.println("s2 = "
+ s2);
for (int i=1;i<=s1.getBytes().length;i++){
x = s1.getBytes()[i-1];
if (x<0) x = 256 + x;
System.out.println("s1.getBytes()["
+ (i-1) + "] = "
+ x);
n2 = Math.abs((x * n2 + 0xf48)) % 1000000;
}
System.out.println("n2 = "
+ n2);
for (int i=2;
i<=s2.getBytes().length;
i++){
x = s2.getBytes()[i-1];
if (x<0) x = 256 + x;
System.out.println("s2.getBytes()["
+ (i-1) + "] = "
+ x);
n2 = Math.abs((x* n2 + 0x0F83)) % 1000000;
}
System.out.println("n2 = "
+ n2);
n2 = 10705672 + Math.abs((n2+n1) *(s1.getBytes().length + s2.getBytes().length));
System.out.println("n2 = "
+ n2);
s5 = zjs + String.format("%d", n2).substring(0, 6);
System.out.println("s5 = "
+ s5);
n2 = Integer.parseInt(s5);
System.out.println("n2 = "
+ n2);
n2 = 137964276 + Math.abs(((n2 / 181) * 196) ^ 39694322);
System.out.println("n2 = "
+ n2);
s1 = String.format("%d", n2).substring(0, 8);
s2 = "73461852";
System.out.println("s1 = "
+ s1);
System.out.println("s2 = "
+ s2);
for (int i=1;
i<=8;
i++){
x = s2.getBytes()[i-1];
if (x<0) x = 256 + x;
s4 = s4 + s1.charAt(x- (int)('1'));
}
System.out.println("s4 = "
+ s4);
s6 = s4 + '-' + s5;
System.out.println("s6 = "
+ s6);
//答案 28741985-052297382
}
}