{"id":261853,"date":"2015-07-20T13:19:03","date_gmt":"2015-07-20T09:19:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=261853"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=261853","title":{"rendered":"\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0438 \u043f\u043e\u0434 .NET \u0434\u043b\u044f \u0447\u0430\u0439\u043d\u0438\u043a\u043e\u0432"},"content":{"rendered":"<p>     \t<img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/f3c\/b5f\/f0f\/f3cb5ff0f3019c035c30c669123d6af8.jpg\" alt=\"image\"\/><\/p>\n<p>  \u042d\u0442\u043e \u043a\u0440\u0430\u0442\u043a\u043e\u0435 \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044e \u043f\u043e\u0434 .NET \u0434\u043b\u044f \u0447\u0430\u0439\u043d\u0438\u043a\u043e\u0432, \u043a\u0430\u043a \u0438 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0437 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430. \u0417\u0434\u0435\u0441\u044c \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0432\u0435\u0449\u0438 \u0438 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0443\u0433\u043b\u0443\u0431\u043b\u0435\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u043d\u0438\u0439.<\/p>\n<p>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e \u0445\u044d\u0448\u0438<\/h2>\n<p>  \u0425\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043b\u044e\u0431\u043e\u0439 \u0434\u043b\u0438\u043d\u044b \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u0430\u0439\u0442\u043e\u0432 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b.<br \/>  \u0425\u044d\u0448 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043e\u0434\u043d\u043e\u0441\u0442\u043e\u0440\u043e\u043d\u043d\u044e\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0435\u043b\u044c\u0437\u044f \u0440\u0435\u0432\u0435\u0440\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043f\u0430\u0440\u043e\u043b\u0435\u0439. \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0445\u044d\u0448, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0430\u043c \u043f\u0430\u0440\u043e\u043b\u044c \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f. \u0414\u043b\u0438\u043d\u0430 \u0445\u044d\u0448\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c \u0445\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<br \/>  \u0412 .NET \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0445\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (\u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 HashAlgorithm):  <\/p>\n<ul>\n<li>MD5 \u2014 \u0434\u043b\u0438\u043d\u0430 128 \u0431\u0438\u0442\u043e\u0432<\/li>\n<li>SHA (Secure Hash Algorithm) \u2014 \u0442\u0430\u043a\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0435\u0442, \u043d\u043e \u0435\u0441\u0442\u044c SHA1 (160 \u0431\u0438\u0442\u043e\u0432), SHA256, SHA384, SHA512<\/li>\n<li>KeydHashAlgorithm (\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u043a\u0430\u043a Message Authentication Code). \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043b\u044f\u043c\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/system.security.cryptography.hmac(v=vs.110).aspx\">HMAC<\/a> \u0438 MACTripleDES<\/li>\n<\/ul>\n<p>  \u0412 .NET, \u0435\u0441\u043b\u0438 \u043d\u0435 \u043d\u0443\u0436\u0435\u043d \u0445\u044d\u0448, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 \u043a\u043b\u044e\u0447\u0435, \u0442\u043e, \u043f\u0440\u0438 \u043f\u0440\u043e\u0447\u0438\u0445 \u0440\u0430\u0432\u043d\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u043d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0438\u0439 \u0434\u0435\u043d\u044c, \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c SHA512. MD5 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0441\u0442\u0430\u0440\u0435\u043b \u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u043d. SHA512 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e (\u0443\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e SHA1). \u0412\u043e\u043e\u0431\u0449\u0435-\u0442\u043e \u0432\u0441\u0451 \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u043e SHA \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u043e. \u0421\u0430\u043c\u044b\u0439 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0439 MACTripleDES. \u0421\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u043e HMAC \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432 \u0434\u0432\u0430-\u0447\u0435\u0442\u044b\u0440\u0435 \u0440\u0430\u0437\u0430 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435, \u0447\u0435\u043c SHA.<\/p>\n<p>  \u0425\u044d\u0448\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043b\u044e\u0447\u0430 \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0437\u0430\u0449\u0438\u0442\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0442 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0439. \u0417\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u043e\u0441\u044b\u043b\u0430\u0435\u043c\u044b\u0435 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c\u0441\u044f \u043d\u0430 \u043f\u0440\u0435\u0434\u043c\u0435\u0442 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0439. \u0415\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0431\u044b\u043b\u0438 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u044b, \u0442\u043e \u0445\u044d\u0448\u0438 \u043d\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0443\u0442. \u041f\u0440\u0438 \u0437\u0430\u0449\u0438\u0442\u0435 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0435\u043b\u044c\u0437\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0445\u044d\u0448, \u0431\u0435\u0437 \u043a\u043b\u044e\u0447\u0430. \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e, \u0442\u043e\u0433\u0434\u0430 \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0431\u0435\u0440\u0451\u0442 \u0432\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0445\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043d\u0430\u0439\u0434\u0451\u0442 \u043d\u0443\u0436\u043d\u044b\u0439, \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u0442 \u043d\u0443\u0436\u043d\u044b\u0439 \u0445\u044d\u0448 \u0438 \u0442\u043e\u0433\u0434\u0430, \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f, \u043a\u0430\u043a \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u043d\u0430 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441. \u0414\u043b\u044f \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0449\u0438\u0442\u044b \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u043e\u0439\u0442\u0438 HMACSHA1 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0445\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043d\u0430 \u043a\u043b\u044e\u0447\u0435. \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0432 \u043f\u043e\u043b\u043d\u044b\u0439 \u0440\u043e\u0441\u0442 \u0432\u0441\u0442\u0430\u0451\u0442 \u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0435\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430.<\/p>\n<pre><code class=\"cs\">public static byte[] ComputeHmacsha1(byte[] data, byte[] key) {       using (var hmac = new HMACSHA1(key))       {             return hmac.ComputeHash(data);       } } <\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0443 \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a\u0430 \u043e\u0441\u0442\u0430\u0432\u0430\u043b\u043e\u0441\u044c \u043c\u0435\u043d\u044c\u0448\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u043d\u0430 \u0441\u0431\u043e\u0440 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0438\u043c \u0445\u044d\u0448\u0435\u0439 \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u0430 \u0441 \u0446\u0435\u043b\u044c\u044e \u043f\u043e\u0438\u0441\u043a\u0430 \u043a\u043b\u044e\u0447\u0430, \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u043b\u044c. <br \/>  \u0421\u043e\u043b\u044c \u2014 \u044d\u0442\u043e \u043d\u0435\u043a\u0438\u0439 \u0440\u0430\u043d\u0434\u043e\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u00ab\u043a\u043b\u044e\u0447\u00bb, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u044d\u043d\u0442\u0440\u043e\u043f\u0438\u0438 \u043a \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044e. \u0421\u043e\u043b\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043c \u0432\u0438\u0434\u0435. \u0421\u043e\u043b\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0430\u0441\u0441\u043e\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0441\u0435\u0441\u0441\u0438\u0435\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0441\u043e\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u043a\u0430\u0436\u0434\u0443\u044e \u0441\u0435\u0441\u0441\u0438\u044e \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0445\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u043e\u0434\u043d\u0438\u0445 \u0438 \u0442\u0435\u0445 \u0436\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0437\u043d\u044b\u0435. \u0421\u043e\u043b\u044c \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442 \u043f\u0440\u0438 \u0445\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0430\u0440\u043e\u043b\u0435\u0439, \u0447\u0442\u043e\u0431\u044b \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0431\u043e\u0440 \u043f\u043e \u0441\u043b\u043e\u0432\u0430\u0440\u044e, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443 \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a\u0430 \u0435\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c \u0445\u044d\u0448\u0435\u0439. \u0414\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u043e\u043b\u0438 \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0440\u0438\u043f\u0442\u043e\u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0442\u0438\u043f\u0430 RNGCryptoServiceProvider.<br \/>  \u0421\u043e\u043b\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<pre><code class=\"cs\">string salt = GenSalt(32); string GenSalt(int length) {     RNGCryptoServiceProvider p = new RNGCryptoServiceProvider();     var salt = new byte[length];     p.GetBytes(salt);     return Convert.ToBase64String(salt); } <\/code><\/pre>\n<h2>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/h2>\n<p>  \u0412 .NET \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432, \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 SymmetricAlgorithm:  <\/p>\n<ul>\n<li>Rijndael<\/li>\n<li>DES<\/li>\n<li>TripleDES<\/li>\n<li>RC2<\/li>\n<\/ul>\n<p>  \u0412 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u043c\u044b\u043c \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u044b\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c \u0432 .NET \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f Rijndael. \u0422\u0430\u043a\u0436\u0435 \u0445\u043e\u0440\u043e\u0448\u0438 Mars, RC6, Serpent, TwoFish, \u043d\u043e \u0432 .NET \u043e\u043d\u0438 \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b. \u0415\u0441\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u0445. Rijndael \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0431\u043b\u043e\u0447\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<br \/>  \u0411\u043b\u043e\u0447\u043d\u044b\u0439 \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u0440\u0435\u0437\u0430\u043d\u044b \u043d\u0430 \u0431\u043b\u043e\u043a\u0438 \u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0451\u043d \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0431\u043b\u043e\u043a\u043e\u0432.<br \/>  \u041f\u0430\u0434\u0434\u0438\u043d\u0433 (Padding) \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u00ab\u0434\u043e\u0431\u0438\u0432\u0430\u043d\u0438\u044f\u00bb \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0431\u043b\u043e\u0447\u043d\u043e\u0433\u043e \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440.<br \/>  Rijndael \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0436\u0438\u043c\u043e\u0432 \u043f\u0430\u0434\u0434\u0438\u043d\u0433\u0430 \u2014 \u0434\u043e\u0431\u0438\u0432\u0430\u043d\u0438\u044f \u043d\u0443\u043b\u044f\u043c\u0438, \u0434\u043e\u0431\u0438\u0432\u0430\u043d\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c \u0438 \u0435\u0449\u0451 \u043f\u0430\u0440\u0443 \u0440\u0435\u0436\u0438\u043c\u043e\u0432. \u041f\u043e\u0436\u0430\u043b\u0443\u0439, \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043d\u0430\u0434\u0451\u0436\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u044d\u043d\u0442\u0440\u043e\u043f\u0438\u0438 \u044d\u0442\u043e \u0434\u043e\u0431\u0438\u0432\u0430\u043d\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u2014 \u044d\u0442\u043e \u0440\u0435\u0436\u0438\u043c ISO10126.<br \/>  Rijndael \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0434 \u0431\u043b\u043e\u043a\u0430\u043c\u0438. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043b\u0443\u0447\u0448\u0435 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0440\u0435\u0436\u0438\u043c CBC, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u0430 \u0432\u0445\u043e\u0434 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0431\u043b\u043e\u043a\u0430 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u0430\u043a\u0436\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0431\u043b\u043e\u043a\u0430, \u0447\u0442\u043e \u043e\u043f\u044f\u0442\u044c \u0436\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u044d\u043d\u0442\u0440\u043e\u043f\u0438\u044e.<br \/>  IV \u2014 initialization vector (\u0432\u0435\u043a\u0442\u043e\u0440 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438). \u041d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u043f\u043e\u0434\u0430\u0447\u0438 \u043d\u0430 \u0432\u0445\u043e\u0434 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430. \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 Rijndael \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438. \u0414\u043b\u044f \u0434\u0435\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0435\u043a\u0442\u043e\u0440 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u043d\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438 \u043f\u043e\u0441\u044b\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0432 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043c \u0432\u0438\u0434\u0435. <br \/>  \u041c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440:  <\/p>\n<pre><code class=\"cs\">string Encrypt() {    RijndaelManaged cipher = new RijndaelManaged();    cipher.KeySize = 256;    cipher.BlockSize = 256; \/\/ \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 128 \u0434\u043b\u044f \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438 \u0441 AES    cipher.Padding = PaddingMode.ISO10126;    cipher.Mode = CipherMode.CBC;    cipher.Key = &quot;some_super_secret_key&quot;;        ICryptoTransform t = cipher.CreateEncryptor();    string text = &quot;some_text_to_encrypt&quot;;    byte[] textInBytes = Encoding.UTF8.GetBytes(text);    byte[] result = t.TransformFinalBlock(textInBytes, 0, textInBytes.Length);    return Convert.ToBase64String(result); } <\/code><\/pre>\n<p>  \u0412 .NET \u0442\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <b>CryptoStream<\/b>. \u041e\u043d \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u0442\u0438\u043f\u0430 FileStream \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043e\u0434\u0438\u043d CryptoStream, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u043c\u043e\u0436\u043d\u043e \u0432\u043b\u043e\u0436\u0438\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439 CryptoStream, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 FileStream. \u0417\u0430\u0442\u0435\u043c \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 CryptoStream \u0441\u0434\u0435\u043b\u0430\u0442\u044c Write, \u043f\u0435\u0440\u0435\u0434\u0430\u0432 \u0442\u0435\u043a\u0441\u0442, \u0438 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442, \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0432 \u043d\u0435\u043a\u0438\u0439 \u0444\u0430\u0439\u043b.<\/p>\n<h2>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e \u0430\u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/h2>\n<p>  \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0430\u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u044b\u043c\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 \u0434\u043b\u044f \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0439 \u0434\u043b\u044f \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0438. \u0415\u0441\u043b\u0438 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432, \u0442\u043e \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0439 \u043a\u043b\u044e\u0447 \u043c\u043e\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u044b\u043c \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0439 \u043a\u043b\u044e\u0447 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u043c \u0432\u0441\u0435\u043c \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0430\u043c \u043e\u0431\u043c\u0435\u043d\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438. <br \/>  \u0410\u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432 100-1000 \u0440\u0430\u0437 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435 \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u044b\u0445. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043e\u0431\u044a\u0451\u043c\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043c\u0438 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0436\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u043e. \u0410\u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e\u0435 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043e \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u044b\u043c. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e\u0433\u043e \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u044b\u0439 \u043a\u043b\u044e\u0447, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445.<br \/>  \u0412 .NET \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b:  <\/p>\n<ul>\n<li>RSA<\/li>\n<li>DSA (\u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0446\u0438\u0444\u0440\u043e\u0432\u044b\u0445 \u043f\u043e\u0434\u043f\u0438\u0441\u0435\u0439)<\/li>\n<li>ECDiffieHellman<\/li>\n<\/ul>\n<p>  \u041e\u0431\u044b\u0447\u043d\u043e \u0434\u043b\u044f RSA \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043a\u043b\u044e\u0447\u0438 \u0434\u043b\u0438\u043d\u043e\u0439 1024, 2048, 4096 \u0431\u0438\u0442\u043e\u0432. \u0414\u043e\u043a\u0430\u0437\u0430\u043d\u043e, \u0447\u0442\u043e RSA \u043d\u0430 \u043a\u043b\u044e\u0447\u0435 \u0434\u043b\u0438\u043d\u043e\u0439 1024 \u2014 \u043d\u0435\u043d\u0430\u0434\u0451\u0436\u0435\u043d, \u0442\u0430\u043a \u0447\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0434\u043b\u0438\u043d\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0438.<br \/>  \u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f RSA:  <\/p>\n<pre><code class=\"cs\"> public class RsaWithCspKey      {         const string ContainerName = &quot;MyContainer&quot;;         public void AssignNewKey()         {             CspParameters cspParams = new CspParameters(1);             cspParams.KeyContainerName = ContainerName;             cspParams.Flags = CspProviderFlags.UseMachineKeyStore;             cspParams.ProviderName = &quot;Microsoft Strong Cryptographic Provider&quot;;             var rsa = new RSACryptoServiceProvider(cspParams) { PersistKeyInCsp = true };         }         public void DeleteKeyInCsp()         {             var cspParams = new CspParameters { KeyContainerName = ContainerName };             var rsa = new RSACryptoServiceProvider(cspParams) { PersistKeyInCsp = false };             rsa.Clear();                                  }         public byte[] EncryptData(byte[] dataToEncrypt)         {             byte[] cipherbytes;             var cspParams = new CspParameters { KeyContainerName = ContainerName };             using (var rsa = new RSACryptoServiceProvider(2048, cspParams))             {                 cipherbytes = rsa.Encrypt(dataToEncrypt, false);             }             return cipherbytes;         }         public byte[] DecryptData(byte[] dataToDecrypt)         {             byte[] plain;             var cspParams = new CspParameters { KeyContainerName = ContainerName };             using (var rsa = new RSACryptoServiceProvider(2048, cspParams))             {                                                plain = rsa.Decrypt(dataToDecrypt, false);             }             return plain;         }     } <\/code><\/pre>\n<p>  \u0426\u0438\u0444\u0440\u043e\u0432\u044b\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u044b \u043d\u0430 \u0430\u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e\u043c \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0438. \u0426\u0438\u0444\u0440\u043e\u0432\u0430\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u044c \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0438 \u0434\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0442\u043e\u043c\u0443 \u0438\u043b\u0438 \u0438\u043d\u043e\u043c\u0443 \u0430\u0432\u0442\u043e\u0440\u0443. \u041e\u0431\u044b\u0447\u043d\u043e \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<br \/>  1. \u0410\u043b\u0438\u0441\u0430 \u0448\u0438\u0444\u0440\u0443\u0435\u0442 \u0441\u0432\u043e\u0451 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435.<br \/>  2. \u0410\u043b\u0438\u0441\u0430 \u0431\u0435\u0440\u0451\u0442 \u0445\u044d\u0448 \u0441\u0432\u043e\u0435\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f.<br \/>  3. \u0410\u043b\u0438\u0441\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0441\u0432\u043e\u0438\u043c \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u043c \u043a\u043b\u044e\u0447\u043e\u043c \u0434\u043b\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u043d\u0438\u044f.<br \/>  4. \u0410\u043b\u0438\u0441\u0430 \u043f\u043e\u0441\u044b\u043b\u0430\u0435\u0442 \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0445\u044d\u0448 \u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u044c \u0411\u043e\u0431\u0443.<br \/>  5. \u0411\u043e\u0431 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u0445\u044d\u0448 \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<br \/>  6. \u0411\u043e\u0431 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043f\u043e\u0434\u043f\u0438\u0441\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u043a\u043b\u044e\u0447.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u0438:<\/p>\n<pre><code class=\"cs\">public class DigitalSignature     {         private RSAParameters _publicKey;         private RSAParameters _privateKey;         public void AssignNewKey()         {             using (var rsa = new RSACryptoServiceProvider(2048))             {                                 rsa.PersistKeyInCsp = false;                                _publicKey = rsa.ExportParameters(false);                 _privateKey = rsa.ExportParameters(true);                             }         }         public byte[] SignData(byte[] hashOfDataToSign)         {             using (var rsa = new RSACryptoServiceProvider(2048))             {                 rsa.PersistKeyInCsp = false;                 rsa.ImportParameters(_privateKey);                                  var rsaFormatter = new RSAPKCS1SignatureFormatter(rsa);                                 rsaFormatter.SetHashAlgorithm(&quot;SHA256&quot;);                 return rsaFormatter.CreateSignature(hashOfDataToSign);             }         }         public bool VerifySignature(byte[] hashOfDataToSign, byte[] signature)         {             using (var rsa = new RSACryptoServiceProvider(2048))             {                 rsa.ImportParameters(_publicKey);                 var rsaDeformatter = new RSAPKCS1SignatureDeformatter(rsa);                 rsaDeformatter.SetHashAlgorithm(&quot;SHA256&quot;);                 return rsaDeformatter.VerifySignature(hashOfDataToSign, signature);             }         }        } <\/code><\/pre>\n<p>  \u0421\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043e\u0447\u0435\u043d\u044c \u043a\u0440\u0430\u0442\u043a\u0438\u0439 \u043a\u043e\u043d\u0441\u043f\u0435\u043a\u0442 \u0434\u0432\u0443\u0445 \u043a\u0443\u0440\u0441\u043e\u0432 \u0441 Pluralsight: <a href=\"http:\/\/www.pluralsight.com\/courses\/cryptography-introduction-dotnet\">\u00abIntroduction to Cryptography in .NET\u00bb<\/a> \u0438 <a href=\"http:\/\/www.pluralsight.com\/courses\/practical-cryptography-dotnet\">\u00abPractical Cryptography in .NET\u00bb<\/a>.     \t<\/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\/254909\/\"> http:\/\/habrahabr.ru\/post\/254909\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>     \t<img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/f3c\/b5f\/f0f\/f3cb5ff0f3019c035c30c669123d6af8.jpg\" alt=\"image\"\/><\/p>\n<p>  \u042d\u0442\u043e \u043a\u0440\u0430\u0442\u043a\u043e\u0435 \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044e \u043f\u043e\u0434 .NET \u0434\u043b\u044f \u0447\u0430\u0439\u043d\u0438\u043a\u043e\u0432, \u043a\u0430\u043a \u0438 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0437 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430. \u0417\u0434\u0435\u0441\u044c \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0432\u0435\u0449\u0438 \u0438 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0443\u0433\u043b\u0443\u0431\u043b\u0435\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u043d\u0438\u0439.<\/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-261853","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/261853","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=261853"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/261853\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=261853"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=261853"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=261853"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}