![](/img/trans.png)
[英]how do i check if attribute from XML tag is undefined JavaScript (Mirth Connect)
[英]Ho do I run the Bouncy castle algorithm from Mirth Connect?
我有一些關於如何從 Java 調用 Bouncy Castle 算法的好例子。 但我是 Mirth 和 JavaScript 的新手。 請幫我把下面的java程序翻譯成JavaScript?
來源: 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);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.