当前位置:   article > 正文

java代码转js_JAVA代码转成js代码 急急急

java代码转js_JAVA代码转成js代码 急急急

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

private void DesCrypt(byte[] source, byte[] dest, byte[] key,int flg)

{

inti,h,j;

int t;

bytec1,c2;

byte[]buf = new byte[8] ;

byte[] buf1 = new byte[8];

byte[] destbuf = new byte[9];

h = 0 ;

/* 不满16位用FF填充 */

for( i=0; i

if( source[i] != 0)

h++;

}

if(h<16){

for(i=h;i<16;i++)

source[i]='F';

}

//source[16]=0;

for (i=0;i<16;i=i+2) {

/*字符转成十进制数字*/

if( is_digit( source[i] )){

c1 = (byte)(source[i]-'0') ;

}else if( is_xdigit(source[i] )){

c1 = (byte)(source[i]-'A'+10);

}else{

c1 = source[i];

}

if( is_digit( source[i+1] )){

c2 = (byte)(source[i+1]-'0') ;

}else if( is_xdigit(source[i+1] )){

c2 = (byte)(source[i+1]-'A'+10);

}else{

c2 = source[i+1];

}

buf[i/2]=(byte)(c1*0x10+c2);

/*密钥中的字符转换成十进制数字*/

if( is_digit(key[i])){

c1 = (byte)(key[i]-'0') ;

}else if(is_xdigit(key[i])){

c1 = (byte)(key[i]-'A'+10) ;

}else{

c1 = key[i] ;

}

if( is_digit(key[i+1])){

c2 = (byte)(key[i+1]-'0') ;

}else if(is_xdigit(key[i+1])){

c2 = (byte)(key[i+1]-'A'+10) ;

}else{

c2 = key[i+1] ;

}

buf1[i/2]=(byte)(c1*0x10+c2);

}

//Lke_des(buf,destbuf,buf1,flg);

destbuf = encrypt(buf, buf1);

for(i=0;i<8;i++){

if((destbuf[i]&0xFF) > 0x7f ){

dest[i*2] = 'F';

dest[i*2+1] = 'F';

continue;

}

String str = Integer.toHexString(destbuf[i]&0xFF).toUpperCase();

//System.out.println("str:"+str);

if(str.length() == 1)

{

dest[i*2+0] = (byte)("0".charAt(0));

dest[i*2+1] = (byte)(str.charAt(0));

}

else

{

dest[i*2+0] = (byte)(str.charAt(0));

dest[i*2+1] = (byte)(str.charAt(1));

}

//System.out.println("destbuf:"+destbuf);

//for(j=0; j

//dest[i*2+j] = (byte)(str.toUpperCase().charAt(j));

//}

}

}

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/155263
推荐阅读
相关标签
  

闽ICP备14008679号