Update SecretUtils.java

This commit is contained in:
Jesse-Ma
2023-03-08 14:13:20 +08:00
parent 719a386f87
commit 9d80477a45

View File

@@ -1,22 +1,17 @@
package com.flagnote.note.utils;
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.HexUtil;
import cn.hutool.core.util.PrimitiveArrayUtil;
import cn.hutool.core.util.ZipUtil;
import cn.hutool.crypto.Mode;
import cn.hutool.crypto.Padding;
import cn.hutool.crypto.symmetric.AES;
import cn.hutool.crypto.symmetric.XXTEA;
public class SecretUtils {
@@ -24,12 +19,19 @@ public class SecretUtils {
new SecretKeySpec("b9t3pzbmybc66cba".getBytes(), "AES"));
private static XXTEA xxtea = new XXTEA("42268c9ea9b3fddd".getBytes());
private static byte[] prefix = new byte[] {100,111,32,110,111,116,32};
private static byte[] suffix = new byte[] {100,111,32,101,118,105,108};
public static byte[] encodeNote(byte[] text) {
return aesNote.encrypt(text);
// text = PrimitiveArrayUtil.sub(text, 7, text.length-7);
return text;
}
public static byte[] decodeNote(byte[] text) {
return aesNote.decrypt(text);
// text = PrimitiveArrayUtil.addAll(prefix,text,suffix);
return text;
}
public static String aesEncode(String word,String keyWord) {