Change the prompt for RSA when to input the key path

This commit is contained in:
xiaoyu830411
2012-08-27 16:49:06 +08:00
parent 5891255dbb
commit 6ff32a749f
@@ -41,8 +41,11 @@ public class RsaAction implements Action {
}
private void encrypt() {
System.out.println("注意: 如果输入的不是该工具生成的私钥, 请转成PKCS#8格式, 使用下面命令");
System.out.println("openssl pkcs8 -topk8 -inform PEM -outform DER -in 原来的Key -nocrypt > 输出文件");
String filePath = System.console().readLine("[RSA]请输入私钥文件路径[如果直接回车将使用默认私钥]: ");
byte[] key = null;
if (filePath == null || filePath.length() == 0) {
key = Base64.base64ToByteArray(DEFAULT_PRIVATE_KEY_STRING);
@@ -154,22 +157,4 @@ public class RsaAction implements Action {
}
}
public static void main(String[] args) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
FileInputStream in = null;
try {
in = new FileInputStream("/Users/yangkingsel/druid.public.key");
byte[] buf = new byte[512/8];
int len;
while ((len = in.read(buf)) != -1) {
out.write(buf, 0, len);
}
System.out.println(Base64.byteArrayToBase64(out.toByteArray()));
} finally {
if (in != null) {
in.close();
}
}
}
}