{"action":"opened","issue":{"url":"https://api.github.com/repos/openpgpjs/openpgpjs/issues/443","repository_url":"https://api.github.com/repos/openpgpjs/openpgpjs","labels_url":"https://api.github.com/repos/openpgpjs/openpgpjs/issues/443/labels{/name}","comments_url":"https://api.github.com/repos/openpgpjs/openpgpjs/issues/443/comments","events_url":"https://api.github.com/repos/openpgpjs/openpgpjs/issues/443/events","html_url":"https://github.com/openpgpjs/openpgpjs/issues/443","id":150568917,"number":443,"title":"Add Key.encrypt(passphrase) to exported API","user":{"login":"NSkelsey","id":1095794,"avatar_url":"https://avatars.githubusercontent.com/u/1095794?v=3","gravatar_id":"","url":"https://api.github.com/users/NSkelsey","html_url":"https://github.com/NSkelsey","followers_url":"https://api.github.com/users/NSkelsey/followers","following_url":"https://api.github.com/users/NSkelsey/following{/other_user}","gists_url":"https://api.github.com/users/NSkelsey/gists{/gist_id}","starred_url":"https://api.github.com/users/NSkelsey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NSkelsey/subscriptions","organizations_url":"https://api.github.com/users/NSkelsey/orgs","repos_url":"https://api.github.com/users/NSkelsey/repos","events_url":"https://api.github.com/users/NSkelsey/events{/privacy}","received_events_url":"https://api.github.com/users/NSkelsey/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-04-23T15:52:56Z","updated_at":"2016-04-23T15:52:56Z","closed_at":null,"body":"In the API documentation we find [`key.prototype.decrypt`](https://openpgpjs.org/openpgpjs/doc/key.js.html#line373). However, there is no accompanying `key.prototype.encrypt` for [`Key`](https://openpgpjs.org/openpgpjs/doc/module-key-Key.html) objects.\r\n\r\nEither this was a specific design choice or it is genuinely missing – please advise.\r\n\r\nThe current code I use to preform key.encrypt(passphrase) looks like:\r\n```javascript\r\n// lockKeyRing encrypts the private key material of the key using the passed \r\n// password. The primary key and all subkeys are encrypted with the password.\r\n// { string -> bool }\r\nfunction lockKeyRing(password) {\r\n  var w = true;\r\n  w = w && keyRing.privateKey.primaryKey.encrypt(password);\r\n  keyRing.privateKey.subKeys.forEach(function(sk) {\r\n      w = w && sk.subKey.encrypt(password);\r\n   });\r\n  return w;\r\n}\r\n```\r\n\r\n\r\nP.S. Thanks for the library it is fantastic!"}}