From d451118d4be05f180cfe1f99bc5904f74db8cc3f Mon Sep 17 00:00:00 2001
From: hxb <hxb@hdlchina.com.cn>
Date: 星期四, 22 二月 2024 15:40:58 +0800
Subject: [PATCH] 引用线上库

---
 HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/ByteUtils.java |   35 ++++++++++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/ByteUtils.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/ByteUtils.java
index 2c2f4a1..e4f6a9d 100644
--- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/ByteUtils.java
+++ b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/ByteUtils.java
@@ -203,8 +203,41 @@
     }
 
     public static int byteArrayToInt(byte[] b) {
-        return (b[0] & 0xFF) * 256 * 256 * 256 + (b[1] & 0xFF) * 256 * 256 + (b[2] & 0xFF) * 256 + (b[3] & 0xFF);
+        int i = (b[0] & 0xFF) * 256 * 256 * 256 + (b[1] & 0xFF) * 256 * 256 + (b[2] & 0xFF) * 256 + (b[3] & 0xFF);
+        return i;
     }
 
+    /**
+     * 瑙e瘑
+     *
+     * @param contentByte 寰呰В瀵嗗緟瀛楃涓瞙exStr
+     * @param contentByte 瀵嗛挜
+     * @return
+     */
+    public static byte[] decrypt(byte[] contentByte) {
+        try {
+            //KEY杞崲
+            Key key = new SecretKeySpec("HDLRDCENTER1985.".getBytes(), "AES");
+            //瑙e瘑
+            Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding");
+            IvParameterSpec ivps = new IvParameterSpec("HDLRDCENTER1985.".getBytes());
+            cipher.init(Cipher.DECRYPT_MODE, key, ivps);
+            byte[] result = cipher.doFinal(contentByte);
+            return result;
+        } catch (NoSuchAlgorithmException e) {
+            LogUtils.e(e.getMessage());
+        } catch (InvalidKeyException e) {
+            LogUtils.e(e.getMessage());
+        } catch (NoSuchPaddingException e) {
+            LogUtils.e(e.getMessage());
+        } catch (BadPaddingException e) {
+            LogUtils.e(e.getMessage());
+        } catch (IllegalBlockSizeException e) {
+            LogUtils.e(e.getMessage());
+        } catch (InvalidAlgorithmParameterException e) {
+            LogUtils.e(e.getMessage());
+        }
+        return null;
+    }
 
 }

--
Gitblit v1.8.0