android客户端手机号码解密方法(2)
来源:未知 责任编辑:责任编辑 发表时间:2014-05-26 10:58 点击:次
DESKeySpec localDESKeySpec = new DESKeySpec(key);
SecretKey localSecretKey = SecretKeyFactory.getInstance("DES")
.generateSecret(localDESKeySpec);
Cipher localCipher = Cipher.getInstance("DES");
localCipher.init(1, localSecretKey, localSecureRandom);
return localCipher.doFinal(paramArrayOfByte);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static byte[] convertHexString(String text) {
byte digest[] = new byte[text.length() / 2];
for (int i = 0; i < digest.length; i++) {
String byteString = text.substring(2 * i, 2 * i + 2);
int byteValue = Integer.parseInt(byteString, 16);
digest[i] = (byte) byteValue;
}
return digest;
}
public static String toHexString(byte b[]) {
StringBuffer hexString = new StringBuffer();
for (int i = 0; i < b.length; i++) {
String plainText = Integer.toHexString(0xff & b[i]);
if (plainText.length() < 2)
plainText = "0" + plainText;
hexString.append(plainText);
}
return hexString.toString();
}
}
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>