From 2142d6522a1a5ef5647a540cab12983ccef20414 Mon Sep 17 00:00:00 2001 From: Looly Date: Mon, 24 Oct 2022 19:45:11 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=B1=E4=BA=8E=E5=AF=B9=E4=BA=8EASCII?= =?UTF-8?q?=E7=9A=84=E7=BC=96=E7=A0=81=E8=A7=A3=E7=A0=81=E6=9C=89=E7=BC=BA?= =?UTF-8?q?=E9=99=B7=EF=BC=8C=E4=B8=94=E8=BF=99=E7=A7=8DBCD=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E5=B9=B6=E4=B8=8D=E8=A7=84=E8=8C=83=EF=BC=8C=E5=9B=A0?= =?UTF-8?q?=E6=AD=A4BCD=E6=A0=87=E8=AE=B0=E4=B8=BA=E5=BC=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + hutool-core/src/main/java/cn/hutool/core/codec/BCD.java | 2 ++ hutool-core/src/test/java/cn/hutool/core/codec/BCDTest.java | 6 +++--- .../cn/hutool/crypto/asymmetric/AsymmetricDecryptor.java | 6 ++++++ .../cn/hutool/crypto/asymmetric/AsymmetricEncryptor.java | 4 ++++ 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8311dd68d..f7226214e 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ ### 🐞Bug修复 * 【db 】 修复分页时order by截断问题(issue#I5X6FM@Gitee) * 【core 】 修复Partition计算size除数为0报错问题(pr#2677@Github) +* 【core 】 由于对于ASCII的编码解码有缺陷,且这种BCD实现并不规范,因此BCD标记为弃用(issue#I5XEC6@Gitee) ------------------------------------------------------------------------------------------------------------- # 5.8.9 (2022-10-22) diff --git a/hutool-core/src/main/java/cn/hutool/core/codec/BCD.java b/hutool-core/src/main/java/cn/hutool/core/codec/BCD.java index b63b79f8c..0bd558a04 100644 --- a/hutool-core/src/main/java/cn/hutool/core/codec/BCD.java +++ b/hutool-core/src/main/java/cn/hutool/core/codec/BCD.java @@ -8,7 +8,9 @@ import cn.hutool.core.lang.Assert; * see http://cuisuqiang.iteye.com/blog/1429956 * @author Looly * + * @deprecated 由于对于ASCII的编码解码有缺陷,且这种BCD实现并不规范,因此会在6.0.0中移除 */ +@Deprecated public class BCD { /** diff --git a/hutool-core/src/test/java/cn/hutool/core/codec/BCDTest.java b/hutool-core/src/test/java/cn/hutool/core/codec/BCDTest.java index 46c99a853..30fef7d4d 100644 --- a/hutool-core/src/test/java/cn/hutool/core/codec/BCDTest.java +++ b/hutool-core/src/test/java/cn/hutool/core/codec/BCDTest.java @@ -7,11 +7,11 @@ public class BCDTest { @Test public void bcdTest(){ - String strForTest = "123456ABCDEF"; + final String strForTest = "123456ABCDEF"; //转BCD - byte[] bcd = BCD.strToBcd(strForTest); - String str = BCD.bcdToStr(bcd); + final byte[] bcd = BCD.strToBcd(strForTest); + final String str = BCD.bcdToStr(bcd); //解码BCD Assert.assertEquals(strForTest, str); } diff --git a/hutool-crypto/src/main/java/cn/hutool/crypto/asymmetric/AsymmetricDecryptor.java b/hutool-crypto/src/main/java/cn/hutool/crypto/asymmetric/AsymmetricDecryptor.java index 74083d609..cda6dedf4 100644 --- a/hutool-crypto/src/main/java/cn/hutool/crypto/asymmetric/AsymmetricDecryptor.java +++ b/hutool-crypto/src/main/java/cn/hutool/crypto/asymmetric/AsymmetricDecryptor.java @@ -103,7 +103,9 @@ public interface AsymmetricDecryptor { * @param charset 加密前编码 * @return 解密后的密文 * @since 4.1.0 + * @deprecated 由于对于ASCII的编码解码有缺陷,且这种BCD实现并不规范,因此会在6.0.0中移除 */ + @Deprecated default byte[] decryptFromBcd(String data, KeyType keyType, Charset charset) { Assert.notNull(data, "Bcd string must be not null!"); final byte[] dataBytes = BCD.ascToBcd(StrUtil.bytes(data, charset)); @@ -118,7 +120,9 @@ public interface AsymmetricDecryptor { * @param charset 加密前编码 * @return 解密后的密文 * @since 4.5.2 + * @deprecated 由于对于ASCII的编码解码有缺陷,且这种BCD实现并不规范,因此会在6.0.0中移除 */ + @Deprecated default String decryptStrFromBcd(String data, KeyType keyType, Charset charset) { return StrUtil.str(decryptFromBcd(data, keyType, charset), charset); } @@ -130,7 +134,9 @@ public interface AsymmetricDecryptor { * @param keyType 密钥类型 * @return 解密后的密文 * @since 4.5.2 + * @deprecated 由于对于ASCII的编码解码有缺陷,且这种BCD实现并不规范,因此会在6.0.0中移除 */ + @Deprecated default String decryptStrFromBcd(String data, KeyType keyType) { return decryptStrFromBcd(data, keyType, CharsetUtil.CHARSET_UTF_8); } diff --git a/hutool-crypto/src/main/java/cn/hutool/crypto/asymmetric/AsymmetricEncryptor.java b/hutool-crypto/src/main/java/cn/hutool/crypto/asymmetric/AsymmetricEncryptor.java index 4e091e8b4..845d69eb2 100755 --- a/hutool-crypto/src/main/java/cn/hutool/crypto/asymmetric/AsymmetricEncryptor.java +++ b/hutool-crypto/src/main/java/cn/hutool/crypto/asymmetric/AsymmetricEncryptor.java @@ -185,7 +185,9 @@ public interface AsymmetricEncryptor { * @param keyType 密钥类型 * @return 加密后的密文 * @since 4.1.0 + * @deprecated 由于对于ASCII的编码解码有缺陷,且这种BCD实现并不规范,因此会在6.0.0中移除 */ + @Deprecated default String encryptBcd(String data, KeyType keyType) { return encryptBcd(data, keyType, CharsetUtil.CHARSET_UTF_8); } @@ -198,7 +200,9 @@ public interface AsymmetricEncryptor { * @param charset 加密前编码 * @return 加密后的密文 * @since 4.1.0 + * @deprecated 由于对于ASCII的编码解码有缺陷,且这种BCD实现并不规范,因此会在6.0.0中移除 */ + @Deprecated default String encryptBcd(String data, KeyType keyType, Charset charset) { return BCD.bcdToStr(encrypt(data, charset, keyType)); }