Try here: https://github.com/fastdata2go/openpgp.js-examples
On 8/18/2015 4:09 PM, Bruno Barberi Gnecco wrote:
> Hi,
>
> I posted this as an issue but it seems more appropriate to this list.
>
> Is it possible to encrypt with a private key and decrypt with a public key? I
> want to send
> data that is guaranteed to be from a sender and I'd rather not send it as
> clear text, so
> just signClearMessage() is not an option. decryptAndVerifyMessage() requires
> both the
> public and private keys, so also not an option.
>
> I can encrypt with a private key easily:
>
> var publicKey = openpgp.key.readArmored(fs.readFileSync('public.key',
> 'utf-8'));
> var privateKey = openpgp.key.readArmored(fs.readFileSync('private.key',
> 'utf-8')).keys[0];
> privateKey.decrypt(PASSPHRASE);
> openpgp.encryptMessage(privateKey, text).then(function(pgpMessage){ //
> yes, private });
>
> But trying to decrypt with a public key does not work. This returns Error:
> Private key is
> not decrypted.
>
> pgpMessage = openpgp.message.readArmored(pgpMessage);
> openpgp.decryptMessage(publicKey.keys[0],
> pgpMessage).then(function(plain) {
> ....
> });
>
> But publicKey.keys[0].decrypt(PASSPHRASE) throw Error: Nothing to decrypt in
> a public key.
>
> Any tips?
>
> _______________________________________________
>
> http://openpgpjs.org
> Subscribe/unsubscribe: http://list.openpgpjs.org
_______________________________________________
http://openpgpjs.org
Subscribe/unsubscribe: http://list.openpgpjs.org