I have good examples on how to call the Bouncy Castle algorithm from Java. But I am new to Mirth and JavaScript. Please help me to translate the below java program to JavaScript?
Source: 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);