实现android的AES加密技术(3)
来源:未知 责任编辑:责任编辑 发表时间:2015-09-17 09:44 点击:次
}
public static byte[] toByte(String hexString) {
int len = hexString.length()/2;
byte[] result = new byte[len];
for (int i = 0; i < len; i++)
result[i] = Integer.valueOf(hexString.substring(2*i, 2*i+2), 16).bytue();
return result;
}
public static String toHex(byte[] buf) {
if (buf == null)
return "";
StringBuffer result = new StringBuffer(2*buf.length);
for (int i = 0; i < buf.length; i++) {
appendHex(result, buf[i]);
}
return result.toString();
}
private final static String HEX = "0123456789ABCDEF";
private static void appendHex(StringBuffer sb, byte b) {
sb.append(HEX.charAt((b>>4)&0x0f)).append(HEX.charAt(b&0x0f));
}
}
加密:String encryptingCode = SimpleCrypto.encrypt(masterPassword,originalText);
解密:String originalText = SimpleCrypto.decrypt(masterpassword, encryptingCode);
作者“技术交流”
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>