更新一个GBK文件到UTF-8

This commit is contained in:
Yutousama 2020-03-16 22:59:18 +08:00
parent 33b65e3b8d
commit 10480cd5de

View File

@ -20,7 +20,7 @@ public class AESTools {
/** /**
* 字节数组转化为大写16进制字符串 * 字节数组转化为大写16进制字符串
* *
* @param b * @param b
* @return * @return
@ -40,7 +40,7 @@ public class AESTools {
} }
/** /**
* 16进制字符串转字节数组 * 16进制字符串转字节数组
* *
* @param s * @param s
* @return * @return
@ -59,12 +59,12 @@ public class AESTools {
/** /**
* AES 加密 * AES 加密
* *
* @param content * @param content
* 明文 * 明文
* @param password * @param password
* 生成秘钥的关键字 * 生成秘钥的关键字
* @return * @return
*/ */
@ -76,8 +76,8 @@ public class AESTools {
cipher.init(Cipher.ENCRYPT_MODE, key, zeroIv); cipher.init(Cipher.ENCRYPT_MODE, key, zeroIv);
byte[] encryptedData = cipher.doFinal(content.getBytes(bm)); byte[] encryptedData = cipher.doFinal(content.getBytes(bm));
// return Base64.encode(encryptedData); // return Base64.encode(encryptedData);
return byte2HexStr(encryptedData); return byte2HexStr(encryptedData);
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
e.printStackTrace(); e.printStackTrace();
} catch (NoSuchPaddingException e) { } catch (NoSuchPaddingException e) {
@ -99,19 +99,19 @@ public class AESTools {
} }
/** /**
* AES 解密 * AES 解密
* *
* @param content * @param content
* 密文 * 密文
* @param password * @param password
* 生成秘钥的关键字 * 生成秘钥的关键字
* @return * @return
*/ */
public static String aesDecrypt(String content, String password) { public static String aesDecrypt(String content, String password) {
try { try {
// byte[] byteMi = Base64.decode(content); // byte[] byteMi = Base64.decode(content);
byte[] byteMi= str2ByteArray(content); byte[] byteMi= str2ByteArray(content);
IvParameterSpec zeroIv = new IvParameterSpec(VIPARA.getBytes()); IvParameterSpec zeroIv = new IvParameterSpec(VIPARA.getBytes());
SecretKeySpec key = new SecretKeySpec(password.getBytes(), "AES"); SecretKeySpec key = new SecretKeySpec(password.getBytes(), "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");