{"id":271860,"date":"2016-01-11T07:19:03","date_gmt":"2016-01-11T04:19:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=271860"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=271860","title":{"rendered":"\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0446\u0438\u0444\u0440\u043e\u0432\u044b\u043c\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u044f\u043c\u0438 PGP \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Bouncy Castle Cryptography Library \u043d\u0430 Java"},"content":{"rendered":"<p>       \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 OpenPGP \u043d\u0430 Java \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Bouncy Castle Cryptography Library \u0441 \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439 \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0432\u0435\u0431-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435. <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/bbe\/0f7\/ebd\/bbe0f7ebd2390f418eae9bda5f286e96.png\" alt=\"image\"\/><br \/>  <a name=\"habracut\"><\/a><br \/>  (<a href=\"https:\/\/commons.wikimedia.org\/wiki\/File:Digital_Signature_diagram_ru.png?uselang=ru\">\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0441\u0445\u0435\u043c\u044b<\/a>)<\/p>\n<h4><a href=\"https:\/\/ru.wikipedia.org\/wiki\/PGP\">PGP<\/a>\/<a href=\"https:\/\/ru.wikipedia.org\/wiki\/PGP#OpenPGP\">OpenPGP<\/a><\/h4>\n<p>  <a href=\"https:\/\/ru.wikipedia.org\/wiki\/PGP#OpenPGP\">OpenPGP<\/a> \u043e\u043f\u0438\u0441\u0430\u043d \u0432 <a href=\"https:\/\/tools.ietf.org\/html\/rfc4880\">RFC 4880<\/a>, \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043e\u043c <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%9A%D1%80%D0%B8%D0%BF%D1%82%D0%BE%D1%81%D0%B8%D1%81%D1%82%D0%B5%D0%BC%D0%B0_%D1%81_%D0%BE%D1%82%D0%BA%D1%80%D1%8B%D1%82%D1%8B%D0%BC_%D0%BA%D0%BB%D1%8E%D1%87%D0%BE%D0%BC\">\u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u043a\u043b\u044e\u0447\u0435\u043c<\/a> \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0446\u0438\u0444\u0440\u043e\u0432\u044b\u043c\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u044f\u043c\u0438 \u0438 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439. \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0441 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0445 \u0441 \u043e\u0442\u0440\u044b\u0442\u044b\u043c \u043a\u043e\u0434\u043e\u043c. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c <a href=\"https:\/\/www.gnupg.org\/\">GnuPG<\/a>, <a href=\"https:\/\/www.kde.org\/applications\/utilities\/kleopatra\/\">Kleopatra<\/a>, \u043d\u0430\u0431\u043e\u0440 \u0443\u0442\u0438\u043b\u0438\u0442 \u0434\u043b\u044f Windows <a href=\"https:\/\/www.gpg4win.org\/\">Gpg4win<\/a> (\u0432 \u043d\u0435\u0433\u043e \u0432\u0445\u043e\u0434\u044f\u0442 GnuPG, Kleopatra \u0438 \u0434\u0440.), \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0434\u043b\u044f Thunderbird <a href=\"https:\/\/www.enigmail.net\">Enigmail<\/a>.<br \/>  \u0414\u043b\u044f Windows \u0438 \u0442\u0430\u043a\u0436\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0430\u043a\u0435\u0442 Symantec Endpoint Encryption, \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u0442\u0430\u043a\u0436\u0435 \u043a\u0430\u043a PGP Desktop (\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 <a href=\"https:\/\/www4.symantec.com\/Vrt\/offer?a_id=184016\">\u043f\u0440\u043e\u0431\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f<\/a>, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u043e\u0441\u043b\u0435 \u0438\u0441\u0442\u0435\u0447\u0435\u043d\u0438\u044f \u0441\u0440\u043e\u043a\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043d\u0435\u043a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u0438\u0445 \u0446\u0435\u043b\u0435\u0439), \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u044b \u0438\u0437 <a href=\"https:\/\/www.symantec.com\/encryption\/\">Symantec Encryption Family<\/a>.<\/p>\n<p>  \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0441\u043c.: <a href=\"https:\/\/ssd.eff.org\/ru\/module\/%D0%B2%D0%B2%D0%B5%D0%B4%D0%B5%D0%BD%D0%B8%D0%B5-%D0%B2-%D1%88%D0%B8%D1%84%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5-%D1%81-%D0%BE%D1%82%D0%BA%D1%80%D1%8B%D1%82%D1%8B%D0%BC-%D0%BA%D0%BB%D1%8E%D1%87%D0%BE%D0%BC-%D0%B8-pgp\">\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u043a\u043b\u044e\u0447\u043e\u043c \u0438 PGP<\/a>, <a href=\"https:\/\/ru.wikipedia.org\/wiki\/PGP#.D0.9C.D0.B5.D1.85.D0.B0.D0.BD.D0.B8.D0.B7.D0.BC_.D1.80.D0.B0.D0.B1.D0.BE.D1.82.D1.8B_PGP\">\u041c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0440\u0430\u0431\u043e\u0442\u044b PGP<\/a>.<\/p>\n<h4>Bouncy Castle Cryptography Library<\/h4>\n<p>  Bouncy Castle Cryptography Library \u0432 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 \u0434\u043b\u044f Java, \u0432 \u0442\u043e\u043c \u0447\u0438\u043b\u0435 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Bouncy_Castle_%28cryptography%29#Spongy_Castle\">\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f<\/a> \u0432 Android. <br \/>  \u042d\u0442\u043e \u043f\u0440\u043e\u0435\u043a\u0442 \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u043a\u043e\u0434\u043e\u043c (GitHub: <a href=\"https:\/\/github.com\/bcgit\/bc-java\">github.com\/bcgit\/bc-java<\/a> ). \u0422\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0439 \u0442\u0435\u043c\u044b \u0438\u043d\u0442\u0435\u0440\u0435\u0441 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b <a href=\"http:\/\/ppgp.sourceforge.net\/\">Portable PGP<\/a> v. 1.x, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u043d\u0430 Java c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Bouncy Castle: <a href=\"http:\/\/sourceforge.net\/p\/ppgp\/code\/\">sourceforge.net\/p\/ppgp\/code<\/a> <\/p>\n<p>  \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 OpenPGP \u0432 Bouncy Castle \u0435\u0441\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u043a\u0435\u0442 <a href=\"https:\/\/www.bouncycastle.org\/docs\/pgdocs1.5on\/index.html\">org.bouncycastle.openpgp<\/a>, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u0438 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. <\/p>\n<h4>\u0421\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u043a\u043b\u044e\u0447<\/h4>\n<p>  \u0420\u0435\u0448\u0430\u0435\u043c\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430: \u0441\u0447\u0438\u0442\u0430\u0442\u044c ASCII-armored Public PGP Key Block (\u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u043a\u043b\u044e\u0447) \u0432 \u0432\u0438\u0434\u0435 String \u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c <a href=\"https:\/\/www.bouncycastle.org\/docs\/pgdocs1.5on\/org\/bouncycastle\/openpgp\/PGPPublicKey.html\">org.bouncycastle.openpgp.PGPPublicKey<\/a> \u043e\u0431\u044a\u0435\u043a\u0442, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 \u0432 BC.<\/p>\n<p>  ASCII-armored \u0444\u043e\u0440\u043c\u0430\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u043b\u044e\u0447 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435, \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u043a\u0438 \u043f\u043e \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0447\u0442\u0435 \u0438 \u0442.\u0434., \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:   <\/p>\n<pre><code class=\"xml\">-----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v2.0.22 (GNU\/Linux)  mQINBFZpf0wBEADo7NZ4Oymw2pVJMfrNEhGwYOT4CGMOTZHQo3rYFrN3yxCsd\/xX r8kWLvkKvEFSD0XfQlq6slA9fnOtsRZl4JlmabKC33ZkB1zhV2c78AhhVMrfFi2a 114xHhOHkR4LOv8mAyyRKd5mpuyYpPKcF2670jXxANeqNQCoKKM\/dPS1uxGapE9Z GG0GFKvIUqKWJUAv7JqOAxtXbAS7JFMwiH16jL\/TeuvKy+0JKvlBM4qxB9S18hi4 GYg1SEATqmeu9E+6alz0L25REYYZZOMja1quF8HywsRY0fSZqCbD+9diP0keAg6z PSDSlgDF4WBUi+c8PoXcRRZq7+XYgky4l8wfGoGnOZKA4GH2SMlNAX8jCIrC7Cpf KPCu6NMY533X735Md6fnWOeuyxz4owPRb6OTt4rYiA3\/9vCu\/waZ1zZx\/wATYORS 1wmOx8ZjogeAPOz6a2PW8hrK0tWbT3ILucC7dxjYfdKHZX2+v3eMGvXFRKss8J5i E5rlJiDnAMoERmIJunh\/EJHz4te+RdMy2jWeDQWGzaFyZC92SUo9tAUJk7xez0KX 5sYzhXjFJX\/17DwFBTXIOYpFjWUyPaQaP7ByWOjZzhCmQxYRBUJSoxOty1ngkZ+B 7zAZSTXh2mukHukRERG1\/\/2FsiBZeapRhAaFWdWnPDN95bg7L7\/qQ5szjQARAQAB tDdWaWt0b3IgQWdleWV2IDxhZ2V5ZXZAaW50ZXJuYXRpb25hbC1hcmJpdHJhdGlv bi5vcmcudWs+iQI\/BBMBAgApBQJWaX9MAhsvBQkB4lLUBwsJCAcDAgEGFQgCCQoL BBYCAwECHgECF4AACgkQzjaf2edxc+UywQ\/+MfYX5BRzl7iSndhr\/vVOEycxZntu 9efMhwQYO87EXT\/cNpRMX\/u2Wzhx70brzFIenvaYTPpVkYKinKv3iEAauJ1wr5\/a PrUxRcfVnBrV8ecWTO6SbNRDePqayst8bBq9rdqnKnpDEv911zk2hjJtCeFDlUkO eiTLgYCVOQ7n0fbN4pjrBGAqDGs2SFjJXAKYJpZqY77P0crHxXCMyukrdj2WxnB7 JyMdmBqViJSo\/MCi7SFXqVQFTvJZVBhTQEUO5KNJA6oAYztYKXBE3AybE528m571 p+HhJ2mOnlNaRu5y12RRQJ7qmKvN9uzHz0+mt8rRk3oYWCYImTMwxDpc1mT39QKs 0WS\/zp5NTIaa+Hvt7V8GH5hmq67YL+JcxEINZGZ+MZmiSKuvGVuqC8ZJpswumVw5 PHtMEL+0zBxZXN41YyfTudssXbvMrNiGIdlQA7CW\/7yMviVR4nyQtFQJwYSL4mva uTQSnihm4Bj6FeYpgGpk1TyIzgtIyaQNSvnlDYFezmN\/JsAs+25EP\/oxyFLaK+ij WdjVmnsDGS4l5BWH\/a8BYPbSnm7YrlYkYCXjTjK1\/EeWA\/tggApISFptc8YQw0Wp Qw0IwhJVPWDVW8nDrv\/1IPhTJgYfIfdmxr32RLhNePEZGZ02zfCP9BrlNKut9\/Hn x1yKWjVaWZO8VtU= =XyhJ -----END PGP PUBLIC KEY BLOCK----- <\/code><\/pre>\n<p>  \u0412 \u0442\u0430\u043a\u043e\u043c \u0432\u0438\u0434\u0435 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u043d \u0432 \u0432\u0435\u0431-\u0444\u043e\u0440\u043c\u0443. \u041c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043a\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043a\u043b\u044e\u0447\u0430, \u0438 \u0437\u0430\u0442\u0435\u043c, \u0441\u043a\u0430\u0436\u0435\u043c, \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0438\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e (\u0441\u0435\u0440\u0432\u0438\u0441 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0445 \u043a\u043b\u044e\u0447\u0435\u0439) \u0438\/\u0438\u043b\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412 BC \u0435\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441 <a href=\"https:\/\/www.bouncycastle.org\/docs\/pgdocs1.5on\/org\/bouncycastle\/openpgp\/PGPPublicKey.html\">PGPPublicKey<\/a>, \u043d\u0430\u0448\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 String, \u0430 \u043f\u043e\u0442\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0435 \u044d\u0442\u0438\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043a\u043b\u044e\u0447\u0435. <\/p>\n<p>  \u0412 \u043f\u0430\u043a\u0435\u0442\u0435 org.bouncycastle.openpgp.examples \u0435\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441 PGPExampleUtil, \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u0435\u0433\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u043d\u0435\u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439, \u043d\u043e \u0435\u0433\u043e \u043a\u043e\u0434 \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0432\u043e\u0435\u0433\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u041c\u0435\u0442\u043e\u0434 \u0438\u0437 PGPExampleUtil \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u0437\u044f\u0442\u044c \u0437\u0430 \u043e\u0441\u043d\u043e\u0432\u0443:  <\/p>\n<pre><code class=\"java\">\/**      * A simple routine that opens a key ring file and loads the first available key      * suitable for encryption.      *       * @param input data stream containing the public key data      * @return the first public key found.      * @throws IOException      * @throws PGPException      *\/     static PGPPublicKey readPublicKey(InputStream input) throws IOException, PGPException     {         PGPPublicKeyRingCollection pgpPub = new PGPPublicKeyRingCollection(             PGPUtil.getDecoderStream(input), new JcaKeyFingerprintCalculator());          \/\/         \/\/ we just loop through the collection till we find a key suitable for encryption, in the real         \/\/ world you would probably want to be a bit smarter about this.         \/\/          Iterator keyRingIter = pgpPub.getKeyRings();         while (keyRingIter.hasNext())         {             PGPPublicKeyRing keyRing = (PGPPublicKeyRing)keyRingIter.next();              Iterator keyIter = keyRing.getPublicKeys();             while (keyIter.hasNext())             {                 PGPPublicKey key = (PGPPublicKey)keyIter.next();                  if (key.isEncryptionKey())                 {                     return key;                 }             }         }          throw new IllegalArgumentException(&quot;Can't find encryption key in key ring.&quot;);     }  <\/code><\/pre>\n<p>  \u0412 <a href=\"http:\/\/sourceforge.net\/p\/ppgp\/code\/HEAD\/tree\/trunk\/src\/portablepgp\/core\/KeyRing.java\">portablepgp.core.KeyRing<\/a> \u043f\u043e\u0445\u043e\u0436\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:   <\/p>\n<pre><code class=\"java\">    public static PGPPublicKeyRing importPublicKey(InputStream iKeyStream) throws IOException {          PGPPublicKeyRing newKey = new PGPPublicKeyRing(new ArmoredInputStream(iKeyStream));          pubring = PGPPublicKeyRingCollection.addPublicKeyRing(pubring, newKey);         savePubring();          return newKey;     } <\/code><\/pre>\n<p>  \u0418\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043d\u0443\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d (\u043f\u0435\u0440\u0432\u044b\u0439) PGPPublicKey \u0438\u0437 PGPPublicKeyRing \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <a href=\"https:\/\/www.bouncycastle.org\/docs\/pgdocs1.5on\/org\/bouncycastle\/openpgp\/PGPPublicKeyRing.html#getPublicKey%28%29\">.getPublicKey()<\/a> \u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 (\u043d\u0430 \u0432\u0445\u043e\u0434\u0435 String, \u043c\u0435\u0442\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 org.bouncycastle.openpgp.PGPPublicKey):   <\/p>\n<pre><code class=\"java\">    public static PGPPublicKey importPublicKey (String armoredPublicPGPkeyBlock) throws IOException {          InputStream in = new ByteArrayInputStream(armoredPublicPGPkeyBlock.getBytes());          PGPPublicKeyRing pgpPublicKeyRing = new PGPPublicKeyRing(new ArmoredInputStream(in), new JcaKeyFingerprintCalculator());          in.close();          PGPPublicKey pgpPublicKey = pgpPublicKeyRing.getPublicKey();          return pgpPublicKey;     } <\/code><\/pre>\n<p>  \u041b\u0438\u0431\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 \u043c\u0435\u0442\u043e\u0434 readPublicKey \u0438\u0437 org.bouncycastle.openpgp.examples.PGPExampleUtil, \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c:   <\/p>\n<pre><code class=\"java\">    public static PGPPublicKey readPublicKeyFromString (String armoredPublicPGPkeyBlock) throws IOException, PGPException {                  InputStream in = new ByteArrayInputStream(armoredPublicPGPkeyBlock.getBytes());          PGPPublicKey pgpPublicKey = readPublicKey(in);          in.close();                  return pgpPublicKey;     } <\/code><\/pre>\n<p>  <\/p>\n<h4>\u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u043b\u044e\u0447\u0430<\/h4>\n<p>  \u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 <a href=\"https:\/\/www.bouncycastle.org\/docs\/pgdocs1.5on\/org\/bouncycastle\/openpgp\/PGPPublicKey.html\">org.bouncycastle.openpgp.PGPPublicKey<\/a> \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u043b\u044e\u0447\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e\u043c \u0438\u043b\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043e \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. <\/p>\n<p>  \u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0432 \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u043c \u0432\u0438\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u043c <a href=\"http:\/\/sourceforge.net\/p\/ppgp\/code\/HEAD\/tree\/trunk\/src\/portablepgp\/core\/PrintablePGPPublicKey.java\">portablepgp.core.PrintablePGPPublicKey<\/a> c \u043c\u0435\u0442\u043e\u0434\u043e\u043c toString():  <\/p>\n<pre><code class=\"java\">package portablepgp.core;  import java.util.Iterator; import org.bouncycastle.openpgp.PGPPublicKey;  \/**  *  * @author Primiano Tucci - http:\/\/www.primianotucci.com\/  *\/ public class PrintablePGPPublicKey  {     PGPPublicKey base;          public PrintablePGPPublicKey(PGPPublicKey iBase){         base = iBase;     }          public PGPPublicKey getPublicKey(){         return base;     }      @Override     public String toString() {         StringBuilder outStr = new StringBuilder();         Iterator iter = base.getUserIDs();                  outStr.append(&quot;[0x&quot;);         outStr.append(Integer.toHexString((int)base.getKeyID()).toUpperCase());         outStr.append(&quot;] &quot;);                  while(iter.hasNext()){             outStr.append(iter.next().toString());             outStr.append(&quot;; &quot;);         }                  return outStr.toString();     }          } <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043a\u043b\u044e\u0447\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 PGPPublicKeyData \u0441 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u043c \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0449\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 <a href=\"https:\/\/www.bouncycastle.org\/docs\/pgdocs1.5on\/org\/bouncycastle\/openpgp\/PGPPublicKey.html\">org.bouncycastle.openpgp.PGPPublicKey<\/a>:   <\/p>\n<pre><code class=\"java\"> import com.google.common.base.Splitter; import com.google.gson.Gson; import org.bouncycastle.openpgp.PGPPublicKey;  import javax.xml.bind.DatatypeConverter; import java.util.Date; import java.util.Iterator; import java.util.List;  public class PGPPublicKeyData {     String keyID;     String userID;     String firstName;     String lastName;     String userEmail;     Date created;     Date exp;     int bitStrength;     String asciiArmored;     String fingerprint;      public PGPPublicKeyData(PGPPublicKey pgpPublicKey) {         \/\/ keyID         StringBuilder keyIDstrBuilder = new StringBuilder();         keyIDstrBuilder.append(&quot;[0x&quot;);         keyIDstrBuilder.append(Integer.toHexString((int) pgpPublicKey.getKeyID()).toUpperCase());         keyIDstrBuilder.append(&quot;] &quot;);         this.keyID = keyIDstrBuilder.toString();         \/\/ userID         StringBuilder userIDstrBuilder = new StringBuilder();         Iterator userIDsIterator = pgpPublicKey.getUserIDs();         while (userIDsIterator.hasNext()) {             userIDstrBuilder.append(userIDsIterator.next().toString());             userIDstrBuilder.append(&quot;; &quot;);         }         this.userID = userIDstrBuilder.toString();         \/\/ user's first and last name and email         List&lt;String&gt; userIdList = Splitter.on(' ').trimResults().omitEmptyStrings().splitToList(userID);         this.firstName = userIdList.get(0);         this.lastName = userIdList.get(1);         String userEmailDirty = userIdList.get(userIdList.size() - 1);         this.userEmail = userEmailDirty.substring(                 1, userEmailDirty.length() - 2         );         \/\/ fingerprint \/\/ [0xE77173E5]           this.fingerprint = DatatypeConverter.printHexBinary(                 pgpPublicKey.getFingerprint()         );         \/\/ creation date         this.created = pgpPublicKey.getCreationTime();         \/\/ exp date         this.exp = org.apache.commons.lang3.time.DateUtils.addSeconds(created, (int) pgpPublicKey.getValidSeconds());         \/\/ Bit strength         this.bitStrength = pgpPublicKey.getBitStrength();     }      public String toJSON() {         Gson gson = new Gson();         return gson.toJson(this);     }      \/\/    ---------- Getters and Setters:  } <\/code><\/pre>\n<p>  <i>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442<\/i>               <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/274779\/\"> http:\/\/habrahabr.ru\/post\/274779\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 OpenPGP \u043d\u0430 Java \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Bouncy Castle Cryptography Library \u0441 \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439 \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0432\u0435\u0431-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435. <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/bbe\/0f7\/ebd\/bbe0f7ebd2390f418eae9bda5f286e96.png\" alt=\"image\"\/>  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-271860","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/271860","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=271860"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/271860\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=271860"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=271860"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=271860"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}