import javax.crypto.spec.SecretKeySpec;
import javax.crypto.Cipher;
import org.codehaus.jackson.map.ObjectMapper;
public class ED {
private static ObjectMapper mapper = new ObjectMapper();
// 转换16进制字符
private static String enc(byte[] by) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < by.length; i++)
{
String tmp = Integer.toHexString(by[i] & 0xFF);
if (tmp.length() == 1)
sb.append("0");
sb.append(tmp);
}
return sb.toString();
}
// 16进制字符转换数组
private static byte[] dec(String hexStr) {
if (hexStr.length() < 1)
return null;
byte[] result = new byte[hexStr.length() / 2];
for (int i = 0; i < hexStr.length() / 2; i++) {
int high = Integer.parseInt(hexStr.substring(i * 2, i * 2 + 1), 16);
int low = Integer.parseInt(hexStr.substring(i * 2 + 1, i * 2 + 2), 16);
result[i] = (byte) (high * 16 + low);
}
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余2页未读,立即下载