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));

//}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值