From fbbd05825360b086821660269c1f7baf12d66db2 Mon Sep 17 00:00:00 2001 From: Administrator <zhubaomin> Date: 星期六, 13 七月 2024 10:59:04 +0800 Subject: [PATCH] 2024-07-13 朱宝民 wechat、remote 动态连接两套中间件 --- pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtil.java | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtil.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtil.java index f3f8dfc..d0f7034 100644 --- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtil.java +++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtil.java @@ -1035,6 +1035,31 @@ return fromIndex ; } + /** + * 鍗佸叚杩涘埗杞瓧鑺傛暟缁� + * @param hex the hex string + * @return 杩斿洖 byte[] + */ + public static int hex2Bytes_LE(String hex, byte[] bs, int fromIndex) { + if (hex == null || hex.equals("")) { + return fromIndex; + } + hex = hex.toUpperCase(Locale.ENGLISH); + int length = hex.length() / 2; + char[] hexChars = hex.toCharArray(); + byte[] d = new byte[length]; + for (int i = 0; i < length; i++) { + int pos = i * 2; + d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1])); + } + for(int i = 0 ; i < d.length; i++){ + bs[fromIndex++] = d[(d.length - 1) - i] ; + } + return fromIndex ; + } + + + private static final char[] HEX_CHAR = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; // /** // * 灏哹yte[]杞崲涓�16杩涘埗瀛楃涓� -- Gitblit v1.8.0