加载中
kwyxiaoli 2014/06/14 21:10 回答了问题: java string 转为 bytes
求指教
@kwyxiaoli
byte[] result = desUtil.DesEncrypt(getMing.getBytes(), 1)...
kwyxiaoli 2014/06/14 20:54 回答了问题: java string 转为 bytes
已贴出
@kwyxiaoli
byte[] result = desUtil.DesEncrypt(getMing.getBytes(), 1)...
kwyxiaoli 2014/06/14 20:53 回答了问题: java string 转为 bytes
 public byte[] DesEncrypt(byte[] des_data, int flag) {
 byte[] format_key = ByteDataFormat(bytekey, flag);
 byte[] format_data = ByteDataFormat(des_data, flag);
 int datalen = format_data.length;
 int unitcount = datalen / 8;
 byte[] result_data = new byte[datalen];
 for (int i = 0; i < unitcount; i++) {
  byte[] tmpkey = new byte[8];
  byte[] tmpdata = new byte[8];
  System.arraycopy(format_key, 0, tmpkey, 0, 8);
  System.arraycopy(format_data, i * 8, tmpdata, 0, 8);
  byte[] tmpresult = UnitDes(tmpkey, tmpdata, flag);
  System.arraycopy(tmpresult, 0, result_data, i * 8, 8);
 } // 当前为解密过程,去掉加密时产生的填充位
 byte[] decryptbytearray = null;
 if (flag == 0) {
  int total_len = datalen;
  int delete_len = result_data[total_len - 8 - 1];
  delete_len = ((delete_len >= 1) && (delete_len <= 8)) ? delete_len : 0;
  decryptbytearray = new byte[total_len - delete_len - 8];
  boolean del_flag = true;
  for (int k = 0; k < delete_len; k++) {
   if (delete_len != result_data[total_len - 8 - (k + 1)])
    del_flag = false;
  }
if (del_flag == true) {
   System.arraycopy(result_data, 0, decryptbytearray, 0, total_len- delete_len - 8);
  }
 }
 return (flag == 1) ? result_data : decryptbytearray;
}
@kwyxiaoli
byte[] result = desUtil.DesEncrypt(getMing.getBytes(), 1)...
kwyxiaoli 2014/06/14 20:52 回答了问题: java string 转为 bytes
那要怎样做才能是两个值相等呢?
@kwyxiaoli
byte[] result = desUtil.DesEncrypt(getMing.getBytes(), 1)...
kwyxiaoli 2014/06/14 20:39 回答了问题: java string 转为 bytes
求指教?
@kwyxiaoli
byte[] result = desUtil.DesEncrypt(getMing.getBytes(), 1)...
kwyxiaoli 2014/06/14 20:38 发布了问题:

没有更多内容

加载失败,请刷新页面

返回顶部
顶部