How to use the openpgp.encrypt function in openpgp

To help you get started, we’ve selected a few openpgp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github transmute-industries / transmute / packages / transmute-did / src / lib / cryptoSuites / openpgpExtensions / cryptoHelpers / index.js View on Github external
const encryptMessage = async ({
  message, privateKey, publicKey, passphrase,
}) => {
  const privKeyObj = (await openpgp.key.readArmored(privateKey)).keys[0];
  await privKeyObj.decrypt(passphrase);

  const options = {
    message: openpgp.message.fromText(message), // input as String (or Uint8Array)
    publicKeys: (await openpgp.key.readArmored(publicKey)).keys, // for encryption
    privateKeys: [privKeyObj], // for signing (optional)
  };

  return openpgp.encrypt(options).then((ciphertext) => {
    const encrypted = ciphertext.data; // '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----'
    return encrypted;
  });
};
github QTGate / CoNET / core / tools / initSystem.ts View on Github external
export const encryptMessage = ( openKeyOption, message: string, CallBack ) => {
	const option = {
		privateKeys: openKeyOption.privateKeys,
		publicKeys: openKeyOption.publicKeys,
		data: message
	}
	//console.log (`encryptMessage `, message )
	return OpenPgp.encrypt ( option ).then ( ciphertext => {
		return CallBack ( null, ciphertext.data )
	}).catch ( CallBack )
}
github QTGate / CoNET / core / tools / initSystem.js View on Github external
exports.encryptMessage = (openKeyOption, message, CallBack) => {
    const option = {
        privateKeys: openKeyOption.privateKeys,
        publicKeys: openKeyOption.publicKeys,
        data: message
    };
    //console.log (`encryptMessage `, message )
    return OpenPgp.encrypt(option).then(ciphertext => {
        return CallBack(null, ciphertext.data);
    }).catch(CallBack);
};
exports.decryptoMessage = (openKeyOption, message, CallBack) => {
github ProtonMail / WebClient / src / app / libraries / pmcrypto.js View on Github external
}).catch(function(err) {
                if (privKeys) {
                    options.privateKeys = [];
                }
                openpgp.encrypt(options).then((ciphertext) => {
                    resolve(ciphertext.data);
                });
            });
        });
github QTGate / CoNET / core / tools / initSystem.ts View on Github external
return options.privateKeys[0].decrypt ( data.toString( 'hex' )).then ( keyOK => {
			return OpenPgp.encrypt ( options ).then ( ciphertext => {
				return Fs.writeFile ( fileName, ciphertext.data, { encoding: 'utf8' }, CallBack )
			}).catch ( CallBack )
		}).catch ( CallBack )
github eluzgin / eos-wallet-keychain / src / components / KeychainForm / index.js View on Github external
hkp.lookup(findOptions).then(function(pubkey) {
                let encryptOptions = {
                    data: record,
                    publicKeys: openpgp.key.readArmored(pubkey).keys
                };
                openpgp.encrypt(encryptOptions).then(function(ciphertext) {
                    return dispatch(doTransfer(values.guardian, 0.0001, ciphertext.data));
                });
            });
        } else {
github kenforthewin / mentat / assets / js / components / App.js View on Github external
async consumeClaim() {
    const userPublicKey = openpgp.key.readArmored(this.props.cryptoReducer.publicKey).keys
    const options = {
      data: this.props.cryptoReducer.groups[this.room].privateKey,
      publicKeys: userPublicKey
    };
    const encryptObject = await openpgp.encrypt(options)
    this.channel.push("consume_claim", {publicKey: this.props.cryptoReducer.publicKey, teamPublicKey: this.props.cryptoReducer.groups[this.room].publicKey, encryptedTeamPrivateKey: encryptObject.data})
    this.pushNewTags(this.state.tags);
    this.setState({
      ...this.state,
      generatingGroupKey: false
    })
  }
github QTGate / CoNET / core / tools / initSystem.js View on Github external
return options.privateKeys[0].decrypt(data.toString('hex')).then(keyOK => {
            return OpenPgp.encrypt(options).then(ciphertext => {
                return Fs.writeFile(fileName, ciphertext.data, { encoding: 'utf8' }, CallBack);
            }).catch(CallBack);
        }).catch(CallBack);
    });
github kenforthewin / mentat / assets / js / components / App.js View on Github external
approveRequest(e) {
    e.preventDefault();
    const data = e.target.dataset;

    const options = {
      data: this.props.cryptoReducer.groups[this.room].privateKey,
      publicKeys: openpgp.key.readArmored(data.publicKey).keys
    };
    

    openpgp.encrypt(options).then((ciphertext) => {
      const encrypted = ciphertext.data;
      this.channel.push("approve_request", { uuid: data.uuid, groupPublicKey: this.props.cryptoReducer.groups[this.room].publicKey, encryptedGroupPrivateKey: encrypted})
    });
  }