mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
Change the prompt for RSA when to input the key path
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user