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