feat: v0.7.1, add --info-json
This commit is contained in:
@@ -64,6 +64,9 @@ public class TinyEncryptArgs {
|
|||||||
@CommandLine.Option(names = {"-I", "--info"}, description = "Encrypt file info")
|
@CommandLine.Option(names = {"-I", "--info"}, description = "Encrypt file info")
|
||||||
boolean fileInfo = false;
|
boolean fileInfo = false;
|
||||||
|
|
||||||
|
@CommandLine.Option(names = {"--info-json"}, description = "Encrypt file info JSON")
|
||||||
|
boolean fileInfoJson = false;
|
||||||
|
|
||||||
@CommandLine.Option(names = {"-P", "--pgp"}, description = "Decrypt use PGP")
|
@CommandLine.Option(names = {"-P", "--pgp"}, description = "Decrypt use PGP")
|
||||||
boolean pgp = false;
|
boolean pgp = false;
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ public class TinyEncryptMainUtil {
|
|||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
try (FileInputStream fis = new FileInputStream(f)) {
|
try (FileInputStream fis = new FileInputStream(f)) {
|
||||||
printOneFileInfo(f, fis);
|
printOneFileInfo(f, fis, tinyEncryptArgs.fileInfoJson);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("Read tiny encrypt file failed: " + e.getMessage() + ", file: " + f);
|
log.warn("Read tiny encrypt file failed: " + e.getMessage() + ", file: " + f);
|
||||||
@@ -158,10 +158,13 @@ public class TinyEncryptMainUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void printOneFileInfo(File f, FileInputStream fis) throws IOException {
|
private static void printOneFileInfo(File f, FileInputStream fis, boolean json) throws IOException {
|
||||||
final Tlv tlv = TlvUtil.readTlv(fis);
|
final Tlv tlv = TlvUtil.readTlv(fis);
|
||||||
final TinyEncryptMeta meta = tlv.getValueAsBytes().asJSONObject(TinyEncryptMeta.class);
|
final TinyEncryptMeta meta = tlv.getValueAsBytes().asJSONObject(TinyEncryptMeta.class);
|
||||||
log.debug("Tiny encrypt meta: " + JSON.toJSONString(meta, true));
|
log.debug("Tiny encrypt meta: " + JSON.toJSONString(meta, true));
|
||||||
|
if (!log.isDebugEnable() && json) {
|
||||||
|
log.info("Tiny encrypt meta: " + JSON.toJSONString(meta, true));
|
||||||
|
}
|
||||||
final StringBuilder sb = new StringBuilder(256);
|
final StringBuilder sb = new StringBuilder(256);
|
||||||
sb.append("Tiny Encrypt File Info\n");
|
sb.append("Tiny Encrypt File Info\n");
|
||||||
sb.append(header("File")).append(f);
|
sb.append(header("File")).append(f);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package me.hatter.tools.tinyencrypt.config;
|
package me.hatter.tools.tinyencrypt.config;
|
||||||
|
|
||||||
public class TinyEncryptConstant {
|
public class TinyEncryptConstant {
|
||||||
public static final String VERSION = "0.7.0";
|
public static final String VERSION = "0.7.1";
|
||||||
|
|
||||||
public static final String ENC_FILE_EXT = ".tinyenc";
|
public static final String ENC_FILE_EXT = ".tinyenc";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user