feat: add bc support
This commit is contained in:
@@ -40,6 +40,9 @@ public class TinyEncryptArgs {
|
||||
@CommandLine.Option(names = {"-P", "--pgp"}, description = "Decrypt use PGP")
|
||||
boolean pgp = false;
|
||||
|
||||
@CommandLine.Option(names = {"--use-jce"}, description = "Use JCE")
|
||||
boolean useJce = false;
|
||||
|
||||
@CommandLine.Parameters(paramLabel = "FILE", description = "Encrypt or Decrypt files")
|
||||
File[] files;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import me.hatter.tools.commons.io.RFile;
|
||||
import me.hatter.tools.commons.log.LogConfig;
|
||||
import me.hatter.tools.commons.log.LogTool;
|
||||
import me.hatter.tools.commons.log.LogTools;
|
||||
import me.hatter.tools.commons.security.bc.BCUtil;
|
||||
import me.hatter.tools.commons.security.digest.Digests;
|
||||
import me.hatter.tools.commons.security.key.KeyPairTool;
|
||||
import me.hatter.tools.commons.security.key.KeyUtil;
|
||||
@@ -157,6 +158,7 @@ public class TinyEncryptMain {
|
||||
if (tinyEncryptArgs == null) {
|
||||
return;
|
||||
}
|
||||
BCUtil.useBc(!tinyEncryptArgs.useJce);
|
||||
// ====================================================================================
|
||||
if (tinyEncryptArgs.doInitConfig) { // --init-config
|
||||
doInitConfig(tinyEncryptArgs);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.hatter.tools.tinyencrypt.config;
|
||||
|
||||
public class TinyEncryptConstant {
|
||||
public static final String VERSION = "0.3.8";
|
||||
public static final String VERSION = "0.3.9";
|
||||
|
||||
public static final String ENC_FILE_EXT = ".tinyenc";
|
||||
}
|
||||
|
||||
@@ -69,9 +69,13 @@ public class EncryptedFileUtil {
|
||||
log.debug("Start process: " + pb.command());
|
||||
Process p = pb.start();
|
||||
p.waitFor();
|
||||
log.info("Finished command");
|
||||
try {
|
||||
byte[] jsonBytes = IOUtil.readToBytes(p.getInputStream());
|
||||
String jsonStr = new String(jsonBytes, StandardCharsets.UTF_8);
|
||||
if (log.isDebugEnable()) {
|
||||
log.debug("Read cmd JSON: " + jsonStr);
|
||||
}
|
||||
JSONObject jo = JSON.parseObject(jsonStr);
|
||||
dataKey = Bytes.fromHex(jo.getString("text_hex")).bytes();
|
||||
} catch (Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user