mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
remove BCD
This commit is contained in:
@@ -1,133 +0,0 @@
|
|||||||
package cn.hutool.core.codec;
|
|
||||||
|
|
||||||
import cn.hutool.core.lang.Assert;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BCD码(Binary-Coded Decimal)亦称二进码十进数或二-十进制代码<br>
|
|
||||||
* BCD码这种编码形式利用了四个位元来储存一个十进制的数码,使二进制和十进制之间的转换得以快捷的进行<br>
|
|
||||||
* see <a href="http://cuisuqiang.iteye.com/blog/1429956">http://cuisuqiang.iteye.com/blog/1429956</a>
|
|
||||||
*
|
|
||||||
* @author Looly
|
|
||||||
*/
|
|
||||||
public class BCD {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字符串转BCD码
|
|
||||||
*
|
|
||||||
* @param asc ASCII字符串
|
|
||||||
* @return BCD
|
|
||||||
*/
|
|
||||||
public static byte[] strToBcd(String asc) {
|
|
||||||
Assert.notNull(asc, "ASCII must not be null!");
|
|
||||||
int len = asc.length();
|
|
||||||
final int mod = len % 2;
|
|
||||||
if (mod != 0) {
|
|
||||||
asc = "0" + asc;
|
|
||||||
len = asc.length();
|
|
||||||
}
|
|
||||||
final byte[] abt;
|
|
||||||
if (len >= 2) {
|
|
||||||
len >>= 1;
|
|
||||||
}
|
|
||||||
final byte[] bbt;
|
|
||||||
bbt = new byte[len];
|
|
||||||
abt = asc.getBytes();
|
|
||||||
int j;
|
|
||||||
int k;
|
|
||||||
for (int p = 0; p < asc.length() / 2; p++) {
|
|
||||||
if ((abt[2 * p] >= '0') && (abt[2 * p] <= '9')) {
|
|
||||||
j = abt[2 * p] - '0';
|
|
||||||
} else if ((abt[2 * p] >= 'a') && (abt[2 * p] <= 'z')) {
|
|
||||||
j = abt[2 * p] - 'a' + 0x0a;
|
|
||||||
} else {
|
|
||||||
j = abt[2 * p] - 'A' + 0x0a;
|
|
||||||
}
|
|
||||||
if ((abt[2 * p + 1] >= '0') && (abt[2 * p + 1] <= '9')) {
|
|
||||||
k = abt[2 * p + 1] - '0';
|
|
||||||
} else if ((abt[2 * p + 1] >= 'a') && (abt[2 * p + 1] <= 'z')) {
|
|
||||||
k = abt[2 * p + 1] - 'a' + 0x0a;
|
|
||||||
} else {
|
|
||||||
k = abt[2 * p + 1] - 'A' + 0x0a;
|
|
||||||
}
|
|
||||||
final int a = (j << 4) + k;
|
|
||||||
final byte b = (byte) a;
|
|
||||||
bbt[p] = b;
|
|
||||||
}
|
|
||||||
return bbt;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ASCII转BCD
|
|
||||||
*
|
|
||||||
* @param ascii ASCII byte数组
|
|
||||||
* @return BCD
|
|
||||||
*/
|
|
||||||
public static byte[] ascToBcd(final byte[] ascii) {
|
|
||||||
Assert.notNull(ascii, "Ascii must be not null!");
|
|
||||||
return ascToBcd(ascii, ascii.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ASCII转BCD
|
|
||||||
*
|
|
||||||
* @param ascii ASCII byte数组
|
|
||||||
* @param ascLength 长度
|
|
||||||
* @return BCD
|
|
||||||
*/
|
|
||||||
public static byte[] ascToBcd(final byte[] ascii, final int ascLength) {
|
|
||||||
Assert.notNull(ascii, "Ascii must be not null!");
|
|
||||||
final byte[] bcd = new byte[ascLength / 2];
|
|
||||||
int j = 0;
|
|
||||||
for (int i = 0; i < (ascLength + 1) / 2; i++) {
|
|
||||||
bcd[i] = ascToBcd(ascii[j++]);
|
|
||||||
bcd[i] = (byte) (((j >= ascLength) ? 0x00 : ascToBcd(ascii[j++])) + (bcd[i] << 4));
|
|
||||||
}
|
|
||||||
return bcd;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BCD转ASCII字符串
|
|
||||||
*
|
|
||||||
* @param bytes BCD byte数组
|
|
||||||
* @return ASCII字符串
|
|
||||||
*/
|
|
||||||
public static String bcdToStr(final byte[] bytes) {
|
|
||||||
Assert.notNull(bytes, "Bcd bytes must be not null!");
|
|
||||||
final char[] temp = new char[bytes.length * 2];
|
|
||||||
char val;
|
|
||||||
|
|
||||||
for (int i = 0; i < bytes.length; i++) {
|
|
||||||
val = (char) (((bytes[i] & 0xf0) >> 4) & 0x0f);
|
|
||||||
temp[i * 2] = (char) (val > 9 ? val + 'A' - 10 : val + '0');
|
|
||||||
|
|
||||||
val = (char) (bytes[i] & 0x0f);
|
|
||||||
temp[i * 2 + 1] = (char) (val > 9 ? val + 'A' - 10 : val + '0');
|
|
||||||
}
|
|
||||||
return new String(temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------- Private method start
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 转换单个byte为BCD
|
|
||||||
*
|
|
||||||
* @param asc ACSII
|
|
||||||
* @return BCD
|
|
||||||
*/
|
|
||||||
private static byte ascToBcd(final byte asc) {
|
|
||||||
final byte bcd;
|
|
||||||
|
|
||||||
if ((asc >= '0') && (asc <= '9')) {
|
|
||||||
bcd = (byte) (asc - '0');
|
|
||||||
} else if ((asc >= 'A') && (asc <= 'F')) {
|
|
||||||
bcd = (byte) (asc - 'A' + 10);
|
|
||||||
} else if ((asc >= 'a') && (asc <= 'f')) {
|
|
||||||
bcd = (byte) (asc - 'a' + 10);
|
|
||||||
} else {
|
|
||||||
bcd = (byte) (asc - 48);
|
|
||||||
}
|
|
||||||
return bcd;
|
|
||||||
}
|
|
||||||
//----------------------------------------------------------------- Private method end
|
|
||||||
}
|
|
@@ -1,5 +1,7 @@
|
|||||||
package cn.hutool.core.codec;
|
package cn.hutool.core.codec.BaseN;
|
||||||
|
|
||||||
|
import cn.hutool.core.codec.Decoder;
|
||||||
|
import cn.hutool.core.codec.Encoder;
|
||||||
import cn.hutool.core.exceptions.UtilException;
|
import cn.hutool.core.exceptions.UtilException;
|
||||||
import cn.hutool.core.text.StrUtil;
|
import cn.hutool.core.text.StrUtil;
|
||||||
|
|
@@ -1,4 +1,4 @@
|
|||||||
package cn.hutool.core.codec;
|
package cn.hutool.core.codec.BaseN;
|
||||||
|
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
import cn.hutool.core.text.StrUtil;
|
import cn.hutool.core.text.StrUtil;
|
@@ -1,4 +1,7 @@
|
|||||||
package cn.hutool.core.codec;
|
package cn.hutool.core.codec.BaseN;
|
||||||
|
|
||||||
|
import cn.hutool.core.codec.Decoder;
|
||||||
|
import cn.hutool.core.codec.Encoder;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
@@ -1,4 +1,4 @@
|
|||||||
package cn.hutool.core.codec;
|
package cn.hutool.core.codec.BaseN;
|
||||||
|
|
||||||
import cn.hutool.core.exceptions.UtilException;
|
import cn.hutool.core.exceptions.UtilException;
|
||||||
import cn.hutool.core.exceptions.ValidateException;
|
import cn.hutool.core.exceptions.ValidateException;
|
@@ -1,5 +1,7 @@
|
|||||||
package cn.hutool.core.codec;
|
package cn.hutool.core.codec.BaseN;
|
||||||
|
|
||||||
|
import cn.hutool.core.codec.Decoder;
|
||||||
|
import cn.hutool.core.codec.Encoder;
|
||||||
import cn.hutool.core.text.StrUtil;
|
import cn.hutool.core.text.StrUtil;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
@@ -1,4 +1,4 @@
|
|||||||
package cn.hutool.core.codec;
|
package cn.hutool.core.codec.BaseN;
|
||||||
|
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
@@ -1,5 +1,7 @@
|
|||||||
package cn.hutool.core.codec;
|
package cn.hutool.core.codec.BaseN;
|
||||||
|
|
||||||
|
import cn.hutool.core.codec.Decoder;
|
||||||
|
import cn.hutool.core.codec.Encoder;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
@@ -1,4 +1,4 @@
|
|||||||
package cn.hutool.core.codec;
|
package cn.hutool.core.codec.BaseN;
|
||||||
|
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
@@ -1,5 +1,6 @@
|
|||||||
package cn.hutool.core.codec;
|
package cn.hutool.core.codec.BaseN;
|
||||||
|
|
||||||
|
import cn.hutool.core.codec.Decoder;
|
||||||
import cn.hutool.core.lang.mutable.MutableInt;
|
import cn.hutool.core.lang.mutable.MutableInt;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
|
|
||||||
@@ -10,7 +11,7 @@ import cn.hutool.core.util.ArrayUtil;
|
|||||||
* @author looly
|
* @author looly
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Base64Decoder implements Decoder<byte[], byte[]>{
|
public class Base64Decoder implements Decoder<byte[], byte[]> {
|
||||||
|
|
||||||
public static Base64Decoder INSTANCE = new Base64Decoder();
|
public static Base64Decoder INSTANCE = new Base64Decoder();
|
||||||
|
|
@@ -1,5 +1,6 @@
|
|||||||
package cn.hutool.core.codec;
|
package cn.hutool.core.codec;
|
||||||
|
|
||||||
|
import cn.hutool.core.codec.BaseN.Base16Codec;
|
||||||
import cn.hutool.core.exceptions.UtilException;
|
import cn.hutool.core.exceptions.UtilException;
|
||||||
import cn.hutool.core.util.CharUtil;
|
import cn.hutool.core.util.CharUtil;
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package cn.hutool.core.codec;
|
package cn.hutool.core.codec;
|
||||||
|
|
||||||
|
import cn.hutool.core.codec.BaseN.Base16Codec;
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.core.text.CharPool;
|
import cn.hutool.core.text.CharPool;
|
||||||
import cn.hutool.core.text.StrUtil;
|
import cn.hutool.core.text.StrUtil;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.core.convert.impl;
|
package cn.hutool.core.convert.impl;
|
||||||
|
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.BaseN.Base64;
|
||||||
import cn.hutool.core.collection.ListUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.convert.AbstractConverter;
|
import cn.hutool.core.convert.AbstractConverter;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
|
@@ -1,18 +0,0 @@
|
|||||||
package cn.hutool.core.codec;
|
|
||||||
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
public class BCDTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void bcdTest(){
|
|
||||||
final String strForTest = "123456ABCDEF";
|
|
||||||
|
|
||||||
//转BCD
|
|
||||||
final byte[] bcd = BCD.strToBcd(strForTest);
|
|
||||||
final String str = BCD.bcdToStr(bcd);
|
|
||||||
//解码BCD
|
|
||||||
Assert.assertEquals(strForTest, str);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,5 +1,6 @@
|
|||||||
package cn.hutool.core.codec;
|
package cn.hutool.core.codec;
|
||||||
|
|
||||||
|
import cn.hutool.core.codec.BaseN.Base32;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import cn.hutool.core.text.StrUtil;
|
import cn.hutool.core.text.StrUtil;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package cn.hutool.core.codec;
|
package cn.hutool.core.codec;
|
||||||
|
|
||||||
|
import cn.hutool.core.codec.BaseN.Base58;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package cn.hutool.core.codec;
|
package cn.hutool.core.codec;
|
||||||
|
|
||||||
|
import cn.hutool.core.codec.BaseN.Base62;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package cn.hutool.core.codec;
|
package cn.hutool.core.codec;
|
||||||
|
|
||||||
|
import cn.hutool.core.codec.BaseN.Base64;
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import cn.hutool.core.text.StrUtil;
|
import cn.hutool.core.text.StrUtil;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.crypto;
|
package cn.hutool.crypto;
|
||||||
|
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.BaseN.Base64;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.crypto;
|
package cn.hutool.crypto;
|
||||||
|
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.BaseN.Base64;
|
||||||
import cn.hutool.core.codec.HexUtil;
|
import cn.hutool.core.codec.HexUtil;
|
||||||
import cn.hutool.core.lang.Validator;
|
import cn.hutool.core.lang.Validator;
|
||||||
import cn.hutool.core.text.StrUtil;
|
import cn.hutool.core.text.StrUtil;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.crypto.asymmetric;
|
package cn.hutool.crypto.asymmetric;
|
||||||
|
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.BaseN.Base64;
|
||||||
import cn.hutool.core.io.FastByteArrayOutputStream;
|
import cn.hutool.core.io.FastByteArrayOutputStream;
|
||||||
import cn.hutool.crypto.CipherWrapper;
|
import cn.hutool.crypto.CipherWrapper;
|
||||||
import cn.hutool.crypto.CryptoException;
|
import cn.hutool.crypto.CryptoException;
|
||||||
|
@@ -1,11 +1,9 @@
|
|||||||
package cn.hutool.crypto.asymmetric;
|
package cn.hutool.crypto.asymmetric;
|
||||||
|
|
||||||
import cn.hutool.core.codec.BCD;
|
|
||||||
import cn.hutool.core.io.IORuntimeException;
|
import cn.hutool.core.io.IORuntimeException;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.core.lang.Assert;
|
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
|
||||||
import cn.hutool.core.text.StrUtil;
|
import cn.hutool.core.text.StrUtil;
|
||||||
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
import cn.hutool.crypto.SecureUtil;
|
import cn.hutool.crypto.SecureUtil;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@@ -17,7 +15,6 @@ import java.nio.charset.Charset;
|
|||||||
* <li>从bytes解密</li>
|
* <li>从bytes解密</li>
|
||||||
* <li>从Hex(16进制)解密</li>
|
* <li>从Hex(16进制)解密</li>
|
||||||
* <li>从Base64解密</li>
|
* <li>从Base64解密</li>
|
||||||
* <li>从BCD解密</li>
|
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @author looly
|
* @author looly
|
||||||
@@ -82,56 +79,4 @@ public interface AsymmetricDecryptor {
|
|||||||
default String decryptStr(final String data, final KeyType keyType) {
|
default String decryptStr(final String data, final KeyType keyType) {
|
||||||
return decryptStr(data, keyType, CharsetUtil.UTF_8);
|
return decryptStr(data, keyType, CharsetUtil.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 解密BCD
|
|
||||||
*
|
|
||||||
* @param data 数据
|
|
||||||
* @param keyType 密钥类型
|
|
||||||
* @return 解密后的密文
|
|
||||||
* @since 4.1.0
|
|
||||||
*/
|
|
||||||
default byte[] decryptFromBcd(final String data, final KeyType keyType) {
|
|
||||||
return decryptFromBcd(data, keyType, CharsetUtil.UTF_8);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分组解密
|
|
||||||
*
|
|
||||||
* @param data 数据
|
|
||||||
* @param keyType 密钥类型
|
|
||||||
* @param charset 加密前编码
|
|
||||||
* @return 解密后的密文
|
|
||||||
* @since 4.1.0
|
|
||||||
*/
|
|
||||||
default byte[] decryptFromBcd(final String data, final KeyType keyType, final Charset charset) {
|
|
||||||
Assert.notNull(data, "Bcd string must be not null!");
|
|
||||||
final byte[] dataBytes = BCD.ascToBcd(StrUtil.bytes(data, charset));
|
|
||||||
return decrypt(dataBytes, keyType);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 解密为字符串,密文需为BCD格式
|
|
||||||
*
|
|
||||||
* @param data 数据,BCD格式
|
|
||||||
* @param keyType 密钥类型
|
|
||||||
* @param charset 加密前编码
|
|
||||||
* @return 解密后的密文
|
|
||||||
* @since 4.5.2
|
|
||||||
*/
|
|
||||||
default String decryptStrFromBcd(final String data, final KeyType keyType, final Charset charset) {
|
|
||||||
return StrUtil.str(decryptFromBcd(data, keyType, charset), charset);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 解密为字符串,密文需为BCD格式,编码为UTF-8格式
|
|
||||||
*
|
|
||||||
* @param data 数据,BCD格式
|
|
||||||
* @param keyType 密钥类型
|
|
||||||
* @return 解密后的密文
|
|
||||||
* @since 4.5.2
|
|
||||||
*/
|
|
||||||
default String decryptStrFromBcd(final String data, final KeyType keyType) {
|
|
||||||
return decryptStrFromBcd(data, keyType, CharsetUtil.UTF_8);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -1,11 +1,9 @@
|
|||||||
package cn.hutool.crypto.asymmetric;
|
package cn.hutool.crypto.asymmetric;
|
||||||
|
|
||||||
import cn.hutool.core.codec.BCD;
|
import cn.hutool.core.codec.BaseN.Base64;
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.HexUtil;
|
||||||
import cn.hutool.core.io.IORuntimeException;
|
import cn.hutool.core.io.IORuntimeException;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
|
||||||
import cn.hutool.core.codec.HexUtil;
|
|
||||||
import cn.hutool.core.text.StrUtil;
|
import cn.hutool.core.text.StrUtil;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@@ -17,7 +15,6 @@ import java.nio.charset.Charset;
|
|||||||
* <li>加密为bytes</li>
|
* <li>加密为bytes</li>
|
||||||
* <li>加密为Hex(16进制)</li>
|
* <li>加密为Hex(16进制)</li>
|
||||||
* <li>加密为Base64</li>
|
* <li>加密为Base64</li>
|
||||||
* <li>加密为BCD</li>
|
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @author looly
|
* @author looly
|
||||||
@@ -177,29 +174,4 @@ public interface AsymmetricEncryptor {
|
|||||||
default String encryptBase64(final InputStream data, final KeyType keyType) {
|
default String encryptBase64(final InputStream data, final KeyType keyType) {
|
||||||
return Base64.encode(encrypt(data, keyType));
|
return Base64.encode(encrypt(data, keyType));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 分组加密
|
|
||||||
*
|
|
||||||
* @param data 数据
|
|
||||||
* @param keyType 密钥类型
|
|
||||||
* @return 加密后的密文
|
|
||||||
* @since 4.1.0
|
|
||||||
*/
|
|
||||||
default String encryptBcd(final String data, final KeyType keyType) {
|
|
||||||
return encryptBcd(data, keyType, CharsetUtil.UTF_8);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分组加密
|
|
||||||
*
|
|
||||||
* @param data 数据
|
|
||||||
* @param keyType 密钥类型
|
|
||||||
* @param charset 加密前编码
|
|
||||||
* @return 加密后的密文
|
|
||||||
* @since 4.1.0
|
|
||||||
*/
|
|
||||||
default String encryptBcd(final String data, final KeyType keyType, final Charset charset) {
|
|
||||||
return BCD.bcdToStr(encrypt(data, charset, keyType));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.crypto.asymmetric;
|
package cn.hutool.crypto.asymmetric;
|
||||||
|
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.BaseN.Base64;
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.crypto.CryptoException;
|
import cn.hutool.crypto.CryptoException;
|
||||||
import cn.hutool.crypto.KeyUtil;
|
import cn.hutool.crypto.KeyUtil;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.crypto.asymmetric;
|
package cn.hutool.crypto.asymmetric;
|
||||||
|
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.BaseN.Base64;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.crypto.digest.mac;
|
package cn.hutool.crypto.digest.mac;
|
||||||
|
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.BaseN.Base64;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.crypto.digest.otp;
|
package cn.hutool.crypto.digest.otp;
|
||||||
|
|
||||||
import cn.hutool.core.codec.Base32;
|
import cn.hutool.core.codec.BaseN.Base32;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import cn.hutool.crypto.digest.HMac;
|
import cn.hutool.crypto.digest.HMac;
|
||||||
import cn.hutool.crypto.digest.HmacAlgorithm;
|
import cn.hutool.crypto.digest.HmacAlgorithm;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.crypto.symmetric;
|
package cn.hutool.crypto.symmetric;
|
||||||
|
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.BaseN.Base64;
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
import cn.hutool.core.codec.HexUtil;
|
import cn.hutool.core.codec.HexUtil;
|
||||||
import cn.hutool.core.text.StrUtil;
|
import cn.hutool.core.text.StrUtil;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.crypto.symmetric;
|
package cn.hutool.crypto.symmetric;
|
||||||
|
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.BaseN.Base64;
|
||||||
import cn.hutool.core.io.IORuntimeException;
|
import cn.hutool.core.io.IORuntimeException;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.crypto.asymmetric;
|
package cn.hutool.crypto.asymmetric;
|
||||||
|
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.BaseN.Base64;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
import cn.hutool.core.codec.HexUtil;
|
import cn.hutool.core.codec.HexUtil;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.crypto.asymmetric;
|
package cn.hutool.crypto.asymmetric;
|
||||||
|
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.BaseN.Base64;
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
import cn.hutool.core.codec.HexUtil;
|
import cn.hutool.core.codec.HexUtil;
|
||||||
import cn.hutool.core.text.StrUtil;
|
import cn.hutool.core.text.StrUtil;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.crypto.digest;
|
package cn.hutool.crypto.digest;
|
||||||
|
|
||||||
import cn.hutool.core.codec.Base32;
|
import cn.hutool.core.codec.BaseN.Base32;
|
||||||
import cn.hutool.crypto.digest.otp.HOTP;
|
import cn.hutool.crypto.digest.otp.HOTP;
|
||||||
import cn.hutool.crypto.digest.otp.TOTP;
|
import cn.hutool.crypto.digest.otp.TOTP;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.crypto.symmetric;
|
package cn.hutool.crypto.symmetric;
|
||||||
|
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.BaseN.Base64;
|
||||||
import cn.hutool.core.codec.HexUtil;
|
import cn.hutool.core.codec.HexUtil;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import cn.hutool.crypto.KeyUtil;
|
import cn.hutool.crypto.KeyUtil;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.extra.qrcode;
|
package cn.hutool.extra.qrcode;
|
||||||
|
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.BaseN.Base64;
|
||||||
import cn.hutool.core.util.ObjUtil;
|
import cn.hutool.core.util.ObjUtil;
|
||||||
import cn.hutool.swing.img.ImgUtil;
|
import cn.hutool.swing.img.ImgUtil;
|
||||||
import com.google.zxing.BarcodeFormat;
|
import com.google.zxing.BarcodeFormat;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.extra.qrcode;
|
package cn.hutool.extra.qrcode;
|
||||||
|
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.BaseN.Base64;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.core.lang.Console;
|
import cn.hutool.core.lang.Console;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.http;
|
package cn.hutool.http;
|
||||||
|
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.BaseN.Base64;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.http;
|
package cn.hutool.http;
|
||||||
|
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.BaseN.Base64;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.lang.Console;
|
import cn.hutool.core.lang.Console;
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
|
@@ -12,7 +12,7 @@ public class IssueI5XBCFTest {
|
|||||||
public void getTest() {
|
public void getTest() {
|
||||||
GlobalCompressStreamRegister.INSTANCE.register("br", BrotliInputStream.class);
|
GlobalCompressStreamRegister.INSTANCE.register("br", BrotliInputStream.class);
|
||||||
|
|
||||||
final HttpResponse s = HttpUtil.createGet("https://static-exp1.licdn.com/sc/h/br/1cp0oqz322bdprj3qd4pojqix")
|
@SuppressWarnings("resource") final HttpResponse s = HttpUtil.createGet("https://static-exp1.licdn.com/sc/h/br/1cp0oqz322bdprj3qd4pojqix")
|
||||||
.header(Header.ACCEPT_ENCODING, "br")
|
.header(Header.ACCEPT_ENCODING, "br")
|
||||||
.execute();
|
.execute();
|
||||||
Console.log(s.body());
|
Console.log(s.body());
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.json.jwt;
|
package cn.hutool.json.jwt;
|
||||||
|
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.BaseN.Base64;
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.json.JSONConfig;
|
import cn.hutool.json.JSONConfig;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.json.jwt;
|
package cn.hutool.json.jwt;
|
||||||
|
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.BaseN.Base64;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.exceptions.ValidateException;
|
import cn.hutool.core.exceptions.ValidateException;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.json.jwt.signers;
|
package cn.hutool.json.jwt.signers;
|
||||||
|
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.BaseN.Base64;
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
import cn.hutool.core.text.StrUtil;
|
import cn.hutool.core.text.StrUtil;
|
||||||
import cn.hutool.crypto.asymmetric.Sign;
|
import cn.hutool.crypto.asymmetric.Sign;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.swing.captcha;
|
package cn.hutool.swing.captcha;
|
||||||
|
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.BaseN.Base64;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.io.IORuntimeException;
|
import cn.hutool.core.io.IORuntimeException;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package cn.hutool.swing.img;
|
package cn.hutool.swing.img;
|
||||||
|
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.BaseN.Base64;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.io.IORuntimeException;
|
import cn.hutool.core.io.IORuntimeException;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
|
Reference in New Issue
Block a user