Update SecretUtils.java
This commit is contained in:
@@ -1,22 +1,17 @@
|
|||||||
package com.flagnote.note.utils;
|
package com.flagnote.note.utils;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.nio.ByteBuffer;
|
||||||
import java.security.InvalidKeyException;
|
import java.util.Arrays;
|
||||||
import java.security.MessageDigest;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
|
|
||||||
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 javax.crypto.spec.SecretKeySpec;
|
||||||
|
|
||||||
import cn.hutool.core.codec.Base64;
|
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.Mode;
|
||||||
import cn.hutool.crypto.Padding;
|
import cn.hutool.crypto.Padding;
|
||||||
import cn.hutool.crypto.symmetric.AES;
|
import cn.hutool.crypto.symmetric.AES;
|
||||||
|
import cn.hutool.crypto.symmetric.XXTEA;
|
||||||
|
|
||||||
public class SecretUtils {
|
public class SecretUtils {
|
||||||
|
|
||||||
@@ -24,12 +19,19 @@ public class SecretUtils {
|
|||||||
new SecretKeySpec("b9t3pzbmybc66cba".getBytes(), "AES"));
|
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) {
|
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) {
|
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) {
|
public static String aesEncode(String word,String keyWord) {
|
||||||
|
|||||||
Reference in New Issue
Block a user