public static byte[] hexToBytes(String hexStr) {
来源:互联网 发布:身份证识别软件 编辑:程序博客网 时间:2024/05/02 02:04
public static byte[] hexToBytes(String hexStr) {
int len = hexStr.length();
hexStr = hexStr.toUpperCase();
byte[] des;
if (len % 2 != 0 || len == 0) {
return null;
} else {
int halfLen = len / 2;
des = new byte[halfLen];
char[] tempChars = hexStr.toCharArray();
for (int i = 0; i < halfLen; ++i) {
char c1 = tempChars[i * 2];
char c2 = tempChars[i * 2 + 1];
int tempI = 0;
if (c1 >= '0' && c1 <= '9') {
tempI += ((c1 - '0') << 4);
} else if (c1 >= 'A' && c1 <= 'F') {
tempI += (c1 - 'A' + 10) << 4;
} else {
return null;
}
if (c2 >= '0' && c2 <= '9') {
tempI += (c2 - '0');
} else if (c2 >= 'A' && c2 <= 'F') {
tempI += (c2 - 'A' + 10);
} else {
return null;
}
des[i] = (byte) tempI;
// System.out.println(des[i]);
}
return des;
}
}
- public static byte[] hexToBytes(String hexStr) {
- public static String toHexStr(byte[] key) {
- public static String byte2Unicode(byte by[]) {
- public static byte[] Unicode2Byte(String s) {
- public static byte[] convertUnicode2UTF8Byte(String instr) {
- public static byte[] stringArray2byteArray(String[] strs) {
- public static String[] byteArray2StringArray(byte[] raw) {
- public static String utf8Byte2String
- hexToBytes
- public static void main(String[] args) 分析
- public static void main(String [] args)
- public Static void main(String[]args){
- public static String getProcessName(Context context) {
- public static File createNewFile(String filePath)
- public static void main(String[] args)
- 浅谈 public static void main(String[] args)
- 关于public static void main(String[] args)
- public static void main(String[] args){…}
- MOBI夹一夹,滤镜特效马上来!
- Google地图大数据量处理的探讨 MarkerClusterer
- linux 下makefile教程(三)
- From Sample Code to Production Driver
- COM调用DLL时报错:Run-Time Check Failure #0
- public static byte[] hexToBytes(String hexStr) {
- Linux 静态库&动态库调用
- PLSQL Developer 9.0 下载+汉化+注册机 以及无法连接到64位数据库解决方法
- 可爱的hello world
- 反射实现 AOP 动态代理模式(Spring AOP 的实现 原理)
- 穷小子口袋里只有1700美元 一天之内变千万富翁 Draw somthing
- SQL SERVER 十六进制转十进制
- public static String byte2Unicode(byte by[]) {
- mini2440:通过JLink烧写BootLoader到Nor Flash