show txt
This commit is contained in:
@@ -113,14 +113,13 @@ public class NoteServiceImpl implements NoteService {
|
|||||||
if (null == note.getTextBytes()) {
|
if (null == note.getTextBytes()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String secretKey = BizKeyUtils.getSecretKey(key);
|
String secretKey = BizKeyUtils.getSecretKey(key);
|
||||||
|
|
||||||
byte[] asebts = ZipUtil.unGzip(note.getTextBytes());
|
byte[] bytes = SecretUtils.aesDecode(note.getTextBytes(),secretKey);
|
||||||
Charset cs = CharsetUtil.CHARSET_UTF_8;
|
bytes = ZipUtil.unGzip(bytes);
|
||||||
ByteBuffer bb = ByteBuffer.allocate(asebts.length);
|
|
||||||
bb.put(asebts).flip();
|
String result = new String(bytes);
|
||||||
CharBuffer cb = cs.decode(bb);
|
|
||||||
String result = SecretUtils.aesDecode(new String(cb.array()), secretKey);
|
|
||||||
if (result.startsWith("FLAGNOTE#")) {
|
if (result.startsWith("FLAGNOTE#")) {
|
||||||
return result.substring(9);
|
return result.substring(9);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,15 +15,6 @@ import cn.hutool.crypto.symmetric.XXTEA;
|
|||||||
|
|
||||||
public class SecretUtils {
|
public class SecretUtils {
|
||||||
|
|
||||||
private static AES aesNote = new AES(Mode.ECB, Padding.PKCS5Padding,
|
|
||||||
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) {
|
||||||
// text = PrimitiveArrayUtil.sub(text, 7, text.length-7);
|
// text = PrimitiveArrayUtil.sub(text, 7, text.length-7);
|
||||||
return text;
|
return text;
|
||||||
@@ -34,24 +25,9 @@ public class SecretUtils {
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String aesEncode(String word,String keyWord) {
|
public static byte[] aesDecode(byte[] bytes,String keyWord) {
|
||||||
AES aes = new AES(Mode.ECB, Padding.PKCS5Padding,
|
AES aes = new AES(Mode.ECB, Padding.NoPadding,
|
||||||
new SecretKeySpec(keyWord.getBytes(), "AES"));
|
new SecretKeySpec(keyWord.getBytes(), "AES"));
|
||||||
return aes.encryptBase64(word);
|
return aes.decrypt(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String aesDecode(String word,String keyWord) {
|
|
||||||
AES aes = new AES(Mode.ECB, Padding.PKCS5Padding,
|
|
||||||
new SecretKeySpec(keyWord.getBytes(), "AES"));
|
|
||||||
return new String(aes.decrypt(Base64.decode(word)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
System.out.println(aesEncode("kaxfn73w2492eb2a","kaxfn73w2492eb2a"));;
|
|
||||||
AES aesNote = new AES(Mode.ECB, Padding.PKCS5Padding,
|
|
||||||
new SecretKeySpec("kaxfn73w2492eb2a".getBytes(), "AES"));
|
|
||||||
System.out.println(aesNote.encryptBase64("kaxfn73w2492eb2a"));
|
|
||||||
System.out.println(new String(aesNote.decrypt(Base64.decode("ycaXaJnQZz9sq/3ezdEB66s4rZv9POL4Q9HRIOWtQPo="))));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user