我现在使用算法RSA/ECB/PKCS1Padding通过Java代码加密字符串,同样需要使用node.js加密.我不知道如何使用算法RSA/ECB/PKCS1Padding通过node.js加密.有什么建议?Java代码是:
public static String encrypt(String source, String publicKey)
throws Exception {
Key key = getPublicKey(publicKey);
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
cipher.init(Cipher.ENCRYPT_MODE, key);
byte[] b = source.getBytes();
byte[] b1 = cipher.doFinal(b);
return new String(Base64.encodeBase64(b1), "UTF-8");
}
Run Code Online (Sandbox Code Playgroud)