orhan / react-native-openpgp

OpenPGP.js adaptation for React-Native
http://openpgpjs.org
39 stars 13 forks source link

Incorrect example in README for asymmetric encryption #8

Open bitsal opened 7 years ago

bitsal commented 7 years ago

Encryption Current version

options = {
...  
    privateKeys: openpgp.readArmoredKey(privkey).keys, // for signing (optional)
...
};

but should be

options = {
  ...
  privateKeys: openpgp.readArmoredKey(privkey).keys
        .map(key =>  openpgp.decryptKey({
                          privateKey: key,
                          passphrase: <passphrase>
                  }).key
         )  // for signing (optional)
...
};

Decryption Current version

options = {
...
  privateKey: openpgp.readArmoredKey(privkey).keys[0], // for decryption
...
};

but should be

options = {
  ...
  privateKey: openpgp.decryptKey({
                          privateKey: openpgp.readArmoredKey(privkey).keys[0],
                          passphrase: <passphrase>
                  }).key 
           // for decryption
...
};