main.js
// public key of the sender to verify signed data
public key of the sender to verify signed data
public key of the sender to verify signed data
async function decrypt(privkey,passphrase,pubkey,message)
{
    privKeyObj = (await openpgp.key.readArmored(privkey)).keys[0];
    await privKeyObj.decrypt(passphrase);
    var options;
    if(pubkey == null) {
        options = {
            message: await openpgp.message.readArmored(message),
            privateKeys: [privKeyObj]
        }
    }
    else
    {
        options = {
            message: await openpgp.message.readArmored(message),
            privateKeys: [privKeyObj],
            publicKeys: (await openpgp.key.readArmored(pubkey)).keys
        }
    }
    var decrypted = await openpgp.decrypt(options);
    var plaintext = await openpgp.stream.readToEnd(decrypted.data);
    return(plaintext);
}
async function decrypt ( privkey , passphrase , pubkey , message ) { privKeyObj = ( await openpgp . key . readArmored ( privkey ) ) . keys [ 0 ] ; await privKeyObj . decrypt ( passphrase ) ; var options ; if ( pubkey == null ) { options = { message : await openpgp . message . readArmored ( message ) , privateKeys : [ privKeyObj ] } } else { options = { message : await openpgp . message . readArmored ( message ) , privateKeys : [ privKeyObj ] , publicKeys : ( await openpgp . key . readArmored ( pubkey ) ) . keys } } var decrypted = await openpgp . decrypt ( options ) ; var plaintext = await openpgp . stream . readToEnd ( decrypted . data ) ; return ( plaintext ) ; }
public key of the sender to verify signed data
public key of the sender to verify signed data
//publicKeys: (await openpgp.key.readArmored(pubkey)).keys