随手一改,不知道结果对不对
public class CDesArithmetic {
public static int mkpass(String s1, String s2, StringBuffer pass)
{
int i, j, k, xx;
int idx[] = new int[13];
String rr;
idx[0] = 13;
idx[1] = 41;
idx[2] = 7;
idx[3] = 17;
idx[4] = 29;
idx[5] = 5;
idx[6] = 19;
idx[7] = 37;
idx[8] = 11;
idx[9] = 47;
idx[10] = 31;
idx[11] = 23;
idx[12] = 53;
rr = s1.substring(0, 5) + s2.substring(0, 8) + "cvicsse-bank3";
xx = 0;
k = 26;
char temp[] = rr.toCharArray();
while (k > 0)
xx += (temp[--k] & 0x7f);
for (i = 0; i < 13; i++) {
j = ((temp[i] & 0x7f) + (temp[25-i] & 0x7f)) / 2;
k = ((xx % j) * idx[i] + idx[i]) % j;
while (k < 48)
k += idx[i];
while (k > ':' && k < '?' || k >= '[' && k <= '`')
k += (i + 1);
while (k > 'z')
k -= (i + 1);
pass.append(k);
}
return 0;
}
/**
* @param args
*/
public static void main(String[] args) {
StringBuffer pass = new StringBuffer();
mkpass("12345", "67890123", pass);
System.out.println("pass=" + pass.toString());
}}
public class CDesArithmetic {
public static int mkpass(String s1, String s2, StringBuffer pass)
{
int i, j, k, xx;
int idx[] = new int[13];
String rr;
idx[0] = 13;
idx[1] = 41;
idx[2] = 7;
idx[3] = 17;
idx[4] = 29;
idx[5] = 5;
idx[6] = 19;
idx[7] = 37;
idx[8] = 11;
idx[9] = 47;
idx[10] = 31;
idx[11] = 23;
idx[12] = 53;
rr = s1.substring(0, 5) + s2.substring(0, 8) + "cvicsse-bank3";
xx = 0;
k = 26;
char temp[] = rr.toCharArray();
while (k > 0)
xx += (temp[--k] & 0x7f);
for (i = 0; i < 13; i++) {
j = ((temp[i] & 0x7f) + (temp[25-i] & 0x7f)) / 2;
k = ((xx % j) * idx[i] + idx[i]) % j;
while (k < 48)
k += idx[i];
while (k > ':' && k < '?' || k >= '[' && k <= '`')
k += (i + 1);
while (k > 'z')
k -= (i + 1);
pass.append(k);
}
return 0;
}
/**
* @param args
*/
public static void main(String[] args) {
StringBuffer pass = new StringBuffer();
mkpass("12345", "67890123", pass);
System.out.println("pass=" + pass.toString());
}}
1、操作员:00001 口令:12345678 密码::H4:D4DBEgN0H
2、操作员:11111 口令:00000000 密码:?M3AA2:@6HFIC
3、操作员:00000 口令:11111111 密码:2J:E@0D2MFGFH
您帮我改的那个程序好象还不对~没有和这个一致
public static String mkpass(String s1,String s2){
int i, j, k, xx;
int[] idx = new int[13];
char[] rr = new char[30];
idx[0] = 13;
idx[1] = 41;
idx[2] = 7;
idx[3] = 17;
idx[4] = 29;
idx[5] = 5;
idx[6] = 19;
idx[7] = 37;
idx[8] = 11;
idx[9] = 47;
idx[10] = 31;
idx[11] = 23;
idx[12] = 53;
for (int l = 0; l < s1.length(); l++) {
rr[l]=s1.charAt(l);
}
for (int l = 0; l < s2.length(); l++) {
rr[5+l]=s2.charAt(l);
}
String s3 = "cvicsse-bank3";
for (int l = 0; l < s3.length(); l++) {
rr[13+l]=s3.charAt(l);
}
String pass = "";
xx = 0;
k = 26;
while (k>0)
xx += (rr[--k] & 0x7f);
for (i = 0; i < 13; i++) {
j = ((rr[i] & 0x7f) + (rr[25-i] & 0x7f)) / 2;
k = ((xx % j) * idx[i] + idx[i]) % j;
while (k < 48)
k += idx[i];
while (k > ':' && k < '?' || k >= '[' && k <= '`')
k += (i + 1);
while (k > 'z')
k -= (i + 1);
pass += (char)k;
}
return pass;
}
public static void main(String[] args)throws Exception {
System.out.println(mkpass("12345","87654321"));
}
}