[英]Ho do I run the Bouncy castle algorithm from Mirth Connect?
I have good examples on how to call the Bouncy Castle algorithm from Java.我有一些关于如何从 Java 调用 Bouncy Castle 算法的好例子。 But I am new to Mirth and JavaScript.但我是 Mirth 和 JavaScript 的新手。 Please help me to translate the below java program to JavaScript?请帮我把下面的java程序翻译成JavaScript?
Source: https://forums.mirthproject.io/forum...ncryption-help来源: https : //forums.mirthproject.io/forum...ncryption-help
public static byte[] encrypt(
byte[] dataToEncrypt,
char[] passPhrase,
int algorithm,
boolean armor
) throws IOException, PGPException, NoSuchProviderException
{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
OutputStream out = bOut;
if (armor)
{
out = new ArmoredOutputStream(out);
}
PGPEncryptedDataGenerator encGen = new PGPEncryptedDataGenerator(new JcePGPDataEncryptorBuilder(algorithm).setSecureRan dom(new SecureRandom()).setProvider("BC"));
encGen.addMethod(new JcePBEKeyEncryptionMethodGenerator(passPhrase).set Provider("BC"));
OutputStream encOut = encGen.open(out, dataToEncrypt.length);
encOut.write(dataToEncrypt);
encOut.close();
if (armor)
{
out.close();
}
return bOut.toByteArray();
}
byte[] encrypted = encrypt(dataToEncrypt, passArray, PGPEncryptedDataGenerator.CAST5, true);
The link here points to a Javascript implementation of the said Algorithm. 这里的链接指向上述算法的 Javascript 实现。 You can implement this within a transformer step of the source connector.您可以在源连接器的转换器步骤中实现这一点。 Better still, you can compile the above code into a jar file that you can load to Mirth Connect's custom libs folder.更好的是,您可以将上述代码编译成一个 jar 文件,您可以将其加载到 Mirth Connect 的自定义库文件夹中。 A good starting point for working with custom Java codes is this对于定制的Java代码工作的一个很好的起点是这个
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.