高手帮我看看吧,实在不知是哪里出问题了
public class des3{
int[] IP={58,50,42,34,26,18,10,2,60,52,44,36,28,20,12,462,54,46,38,30,22,14,6,64,56,48,40,32,24,16,8,
57,49,41,33,25,17,9,1,59,51,43,35,27,19,11,3,61,53,45,37,29,21,13,5,63,55,47,39,31,23,15,7};
char[] read(String s)
{
char[] a=new char[8];
for(int i=0;i<8;i++)
{
a[i]=s.charAt(i);
}
return a;
}
int[] jmsf(char[] y,char[] m)
{
int[] erkey=new int[64];
int[] erdata=new int[64];
int[] dataip=new int[64];
erkey=varyer(y);
erdata=varyer(m);
dataip=varyip(erdata);
return dataip;
}
int[] varyip(int[] s)
{
int[] m=new int[64];
for(int i=0;i<64;i++)
{
m[i]=s[IP[i]-1];
}
return m;
}
int[] varyer(char[] s)
{
int[] zcz=new int[64]; //存对应8个字符的64位二进制
for(int i=0;i<8;i++)
{
for(int j=0;j<8;j++)
{
zcz[(i*8)+7-j]=s[i]%2;
s[i]/=2;
}
}
return zcz;
}
public static void main(String[] args)
{
String zj="Asdfrthj";
String zj2="12345678";
des3 Des=new des3();
char[] mw=Des.read(zj);
char[] my=Des.read(zj2);
int[] shuchu=new int[64];
shuchu=Des.jmsf(my,mw);
System.out.println(shuchu);
}
}
编绎能通过,运行就出现:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:462
at des3.varyip(des3.java:30)
at des3.jmsf(des3.java:22)
at des3.main(des3.java:56)
[[it] 本帖最后由 lulu820830 于 2008-4-12 19:29 编辑 [/it]]