{"id":375156,"date":"2024-05-21T06:17:33","date_gmt":"2024-05-21T06:17:33","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=375156"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=375156","title":{"rendered":"<span>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f SHA256 \u0438 SHA512 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 RUST<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4fe\/56e\/c8c\/4fe56ec8ca76db1705c13f9d7ff1fc6f.png\" alt=\"\" title=\"\" width=\"1344\" height=\"768\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4fe\/56e\/c8c\/4fe56ec8ca76db1705c13f9d7ff1fc6f.png\"\/><\/figure>\n<p>\u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e \u043c\u0435\u043d\u044f \u043f\u043e\u0431\u0443\u0434\u0438\u043b\u0438 2 \u0432\u0435\u0449\u0438:<\/p>\n<ol>\n<li>\n<p>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 \u0432 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0438\u0442\u0435\u0442\u0435<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/companies\/selectel\/articles\/530262\/\" rel=\"noopener noreferrer nofollow\">\u0421\u043b\u0430\u0431\u044b\u0439 \u043f\u0435\u0440\u0435\u0441\u043a\u0430\u0437<\/a> \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 SHA256.<\/p>\n<\/li>\n<\/ol>\n<p>\u042f \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u043f\u0440\u043e\u0431\u0435\u043b\u044b \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0441\u0432\u043e\u0438\u043c\u0438 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u044f\u043c\u0438 \u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u043a\u043e\u0434\u0430 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 Rust. \u0411\u0443\u0434\u0443\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0434\u043b\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 SHA256 \u0438 SHA512. \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u043c \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u0430\u043c. \u0411\u043e\u043b\u0435\u0435 \u043e\u043f\u044b\u0442\u043d\u044b\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442\u0441\u044f. <\/p>\n<p>\u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d \u0432 <a href=\"https:\/\/gitverse.ru\/digit4lsh4d0w\/cryptography\/content\/main\/hand-made-sha\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 GitVerse<\/a>.<\/p>\n<h2>\u0428\u0430\u0433 1 &#8212; \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 \u0431\u043b\u043e\u043a\u0438<\/h2>\n<p>\u041d\u0430 \u0432\u0445\u043e\u0434 \u0445\u044d\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0434\u0430\u044e\u0442\u0441\u044f \u0431\u0430\u0439\u0442\u044b \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f. \u0425\u0430\u0440\u0430\u043a\u0442\u0435\u0440 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043d\u0430\u043c \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u0438 \u043d\u0435\u0432\u0430\u0436\u0435\u043d, \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0447\u0442\u043e-\u0443\u0433\u043e\u0434\u043d\u043e &#8212; \u0442\u0435\u043a\u0441\u0442, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0430\u0443\u0434\u0438\u043e \u0444\u0430\u0439\u043b. \u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0444\u043e\u0440\u043c\u0438\u0442\u044c \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0438\u043c\u0438.<\/p>\n<p>\u0418\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u044b \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0431\u043b\u043e\u043a\u0438, \u0434\u043b\u044f SHA256 \u0440\u0430\u0437\u043c\u0435\u0440 \u0431\u043b\u043e\u043a\u0430 \u0440\u0430\u0432\u0435\u043d 64 \u0431\u0430\u0439\u0442\u0430\u043c (512 \u0431\u0438\u0442), \u0430 \u0434\u043b\u044f SHA512 128 \u0431\u0430\u0439\u0442 (1024 \u0431\u0438\u0442\u0430). \u0414\u0430\u043d\u043d\u044b\u0435 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0438\u043c\u0435\u044e\u0442 \u043d\u0435 \u043a\u0440\u0430\u0442\u043d\u044b\u0439 \u0431\u043b\u043e\u043a\u0430\u043c \u0440\u0430\u0437\u043c\u0435\u0440, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0445 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u0442\u044c. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0435\u0434\u0438\u043d:<\/p>\n<ol>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044e \u0431\u0430\u0439\u0442 <code>0x80<\/code>. \u0412 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u043c \u0432\u0438\u0434\u0435 <code>0x80<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a <code>10000000<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044e \u043d\u0443\u043b\u0435\u0432\u044b\u0435 \u0431\u0430\u0439\u0442\u044b <code>0x00<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044e \u0432\u043e\u0441\u0435\u043c\u044c \u0431\u0430\u0439\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u0438\u043d\u044b \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u043d\u0435\u0441\u0435\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u0438\u043a\u0443. \u0421\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0431\u0430\u0439\u0442\u0430 <code>0x80<\/code> \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u043d\u0443\u043b\u0435\u0432\u044b\u043c\u0438 \u0431\u0430\u0439\u0442\u0430\u043c\u0438 <code>0x00<\/code>. \u042d\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0444\u043e\u0440\u043c\u0443\u043b\u043e\u0439:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"x = b - m - 1 - 8 \\pmod b\" alt=\"x = b - m - 1 - 8 \\pmod b\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ada\/d18\/913\/adad1891374f2d0708c60b705acb0e38.svg\" width=\"245\" height=\"22\"\/><\/p>\n<p>\u0413\u0434\u0435 <code>x<\/code> &#8212; \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0443\u043b\u0435\u0439 \u0434\u043b\u044f \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, <code>b<\/code> &#8212; \u0440\u0430\u0437\u043c\u0435\u0440 \u0431\u043b\u043e\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, <code>m<\/code> &#8212; \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u041c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0442\u043e\u0447\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0443\u043b\u0435\u0439 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c \u0431\u043b\u043e\u043a\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b\u0447\u0438\u0442\u0430\u0435\u043c \u0438\u0437 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0431\u043b\u043e\u043a\u0430 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u0431\u043b\u043e\u043a\u0430. \u041d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u0431\u044b\u0432\u0430\u0442\u044c \u0438 \u043f\u0440\u043e \u0431\u0430\u0439\u0442 <code>0x80<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c 8 \u0431\u0430\u0439\u0442 (64 \u0431\u0438\u0442\u0430) \u0434\u043b\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u0438\u043d\u044b \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9f7\/abc\/4bd\/9f7abc4bde675c80bfceecaa9e235129.png\" alt=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0431\u043b\u043e\u043a\u0430 \u0434\u043b\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 SHA256\" title=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0431\u043b\u043e\u043a\u0430 \u0434\u043b\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 SHA256\" width=\"1440\" height=\"774\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9f7\/abc\/4bd\/9f7abc4bde675c80bfceecaa9e235129.png\"\/><\/p>\n<div><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u0431\u043b\u043e\u043a\u0430 \u0434\u043b\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 SHA256<\/figcaption><\/div>\n<\/figure>\n<p>\u041c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0442\u0430\u043a\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f, \u0447\u0442\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u0438\u043d\u044b \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0441\u0442\u0430 \u043d\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f49\/53b\/b13\/f4953bb138480256f88a7f9047373e5d.png\" alt=\"\u0411\u043b\u043e\u043a, \u0433\u0434\u0435 \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 \u043c\u0435\u0441\u0442\u043e \u0437\u0430\u043d\u044f\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u043c\u0438\" title=\"\u0411\u043b\u043e\u043a, \u0433\u0434\u0435 \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 \u043c\u0435\u0441\u0442\u043e \u0437\u0430\u043d\u044f\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u043c\u0438\" width=\"960\" height=\"480\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f49\/53b\/b13\/f4953bb138480256f88a7f9047373e5d.png\"\/><\/p>\n<div><figcaption>\u0411\u043b\u043e\u043a, \u0433\u0434\u0435 \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 \u043c\u0435\u0441\u0442\u043e \u0437\u0430\u043d\u044f\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u043c\u0438<\/figcaption><\/div>\n<\/figure>\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/companies\/selectel\/articles\/530262\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u0435<\/a>, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u0441\u0441\u044b\u043b\u0430\u043b\u0441\u044f \u0432\u044b\u0448\u0435, \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u0443\u043f\u0443\u0449\u0435\u043d. \u041e\u0434\u043d\u0430\u043a\u043e \u043d\u0430 \u0412\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u0438 \u0432\u0441\u0435 \u044f\u0441\u043d\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u043e. \u041c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0431\u0430\u0439\u0442 <code>0x80<\/code> \u0438 \u043e\u0441\u0442\u0430\u0432\u0448\u0435\u0435\u0441\u044f \u043c\u0435\u0441\u0442\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043d\u0443\u043b\u044f\u043c\u0438. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u0431\u043b\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0443\u043b\u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044f \u0438 8 \u0431\u0430\u0439\u0442 (64 \u0431\u0438\u0442\u0430) \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u0438\u043d\u044b \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cd5\/86e\/eee\/cd586eeee2715a2af4d4ab66584fa815.png\" alt=\"\u0414\u0432\u0430 \u0431\u043b\u043e\u043a\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 SHA256\" title=\"\u0414\u0432\u0430 \u0431\u043b\u043e\u043a\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 SHA256\" width=\"960\" height=\"960\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cd5\/86e\/eee\/cd586eeee2715a2af4d4ab66584fa815.png\"\/><\/p>\n<div><figcaption>\u0414\u0432\u0430 \u0431\u043b\u043e\u043a\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 SHA256<\/figcaption><\/div>\n<\/figure>\n<p>SHA256:<\/p>\n<pre><code class=\"rust\">pub fn sha256(message: &amp;[u8]) -> String {     let mut m = message.to_vec();     m.push(0x80);     if 64 - m.len() % 64 &lt; 8 {         m.append(&amp;mut vec![0u8; 64 - m.len() % 64])     }     m.append(&amp;mut vec![0u8; 64 - m.len() % 64 - 8]);     m.append(&amp;mut (message.len() as u64 * 8).to_be_bytes().to_vec());     let blocks = m.chunks_exact(64);<\/code><\/pre>\n<p>SHA512:<\/p>\n<pre><code class=\"rust\">pub fn sha512(message: &amp;[u8]) -> String {     let mut m = message.to_vec();     m.push(0x80);     if 128 - m.len() % 128 &lt; 8 {         m.append(&amp;mut vec![0u8; 128 - m.len() % 128])     }     m.append(&amp;mut vec![0u8; 128 - m.len() % 128 - 8]);     m.append(&amp;mut (message.len() as u64 * 8).to_be_bytes().to_vec());     let blocks = m.chunks_exact(128);<\/code><\/pre>\n<p>\u041e\u0442\u043b\u0438\u0447\u0438\u0435 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 SHA512 \u0440\u0430\u0437\u043c\u0435\u0440 \u0431\u043b\u043e\u043a \u0432\u0434\u0432\u043e\u0435 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u0443 SHA256, \u0442\u043e \u0435\u0441\u0442\u044c 128 \u0431\u0430\u0439\u0442 (1024 \u0431\u0438\u0442\u0430).<\/p>\n<h2>\u0428\u0430\u0433 2 &#8212; \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439<\/h2>\n<p>\u041c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0432\u0435 \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435. \u041e\u0434\u043d\u0430 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>h<\/code> \u0438 \u0445\u0440\u0430\u043d\u0438\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0448\u0430\u0433\u0430\u0445, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a\u0430\u043a \u0440\u0430\u0437 \u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u0445\u044d\u0448\u0430, \u0430 \u0434\u0440\u0443\u0433\u0430\u044f \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>K<\/code> \u0438 \u0445\u0440\u0430\u043d\u0438\u0442 \u0440\u0430\u0443\u043d\u0434\u043e\u0432\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0441\u0436\u0430\u0442\u0438\u044f.<\/p>\n<p>SHA256:<\/p>\n<pre><code class=\"rust\">let mut h: [u32; 8] = [     0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,     0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19, ]; const K: [u32; 64] = [     0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,     0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,     0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,     0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,     0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,     0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,     0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,     0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,     0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,     0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,     0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,     0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,     0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,     0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,     0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,     0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2, ];<\/code><\/pre>\n<p>SHA512:<\/p>\n<pre><code class=\"rust\">let mut h: [u64; 8] = [     0x6a09e667f3bcc908, 0xbb67ae8584caa73b, 0x3c6ef372fe94f82b, 0xa54ff53a5f1d36f1,     0x510e527fade682d1, 0x9b05688c2b3e6c1f, 0x1f83d9abfb41bd6b, 0x5be0cd19137e2179, ]; const K: [u64; 80] = [     0x428a2f98d728ae22, 0x7137449123ef65cd, 0xb5c0fbcfec4d3b2f, 0xe9b5dba58189dbbc,     0x3956c25bf348b538, 0x59f111f1b605d019, 0x923f82a4af194f9b, 0xab1c5ed5da6d8118,     0xd807aa98a3030242, 0x12835b0145706fbe, 0x243185be4ee4b28c, 0x550c7dc3d5ffb4e2,     0x72be5d74f27b896f, 0x80deb1fe3b1696b1, 0x9bdc06a725c71235, 0xc19bf174cf692694,     0xe49b69c19ef14ad2, 0xefbe4786384f25e3, 0x0fc19dc68b8cd5b5, 0x240ca1cc77ac9c65,     0x2de92c6f592b0275, 0x4a7484aa6ea6e483, 0x5cb0a9dcbd41fbd4, 0x76f988da831153b5,     0x983e5152ee66dfab, 0xa831c66d2db43210, 0xb00327c898fb213f, 0xbf597fc7beef0ee4,     0xc6e00bf33da88fc2, 0xd5a79147930aa725, 0x06ca6351e003826f, 0x142929670a0e6e70,     0x27b70a8546d22ffc, 0x2e1b21385c26c926, 0x4d2c6dfc5ac42aed, 0x53380d139d95b3df,     0x650a73548baf63de, 0x766a0abb3c77b2a8, 0x81c2c92e47edaee6, 0x92722c851482353b,     0xa2bfe8a14cf10364, 0xa81a664bbc423001, 0xc24b8b70d0f89791, 0xc76c51a30654be30,     0xd192e819d6ef5218, 0xd69906245565a910, 0xf40e35855771202a, 0x106aa07032bbd1b8,     0x19a4c116b8d2d0c8, 0x1e376c085141ab53, 0x2748774cdf8eeb99, 0x34b0bcb5e19b48a8,     0x391c0cb3c5c95a63, 0x4ed8aa4ae3418acb, 0x5b9cca4f7763e373, 0x682e6ff3d6b2b8a3,     0x748f82ee5defb2fc, 0x78a5636f43172f60, 0x84c87814a1f0ab72, 0x8cc702081a6439ec,     0x90befffa23631e28, 0xa4506cebde82bde9, 0xbef9a3f7b2c67915, 0xc67178f2e372532b,     0xca273eceea26619c, 0xd186b8c721c0c207, 0xeada7dd6cde0eb1e, 0xf57d4f7fee6ed178,     0x06f067aa72176fba, 0x0a637dc5a2c898a6, 0x113f9804bef90dae, 0x1b710b35131c471b,     0x28db77f523047d84, 0x32caab7b40c72493, 0x3c9ebe0a15c9bebc, 0x431d67c49c100d4c,     0x4cc5d4becb3e42b6, 0x597f299cfc657e2a, 0x5fcb6fab3ad6faec, 0x6c44198c4a475817, ];<\/code><\/pre>\n<p><code>h<\/code> \u0445\u0440\u0430\u043d\u0438\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u0440\u043e\u0431\u043d\u044b\u0445 \u0447\u0430\u0441\u0442\u0435\u0439 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0445 \u043a\u043e\u0440\u043d\u0435\u0439 \u043e\u0442 \u043f\u0435\u0440\u0432\u044b\u0445 \u0432\u043e\u0441\u044c\u043c\u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0447\u0438\u0441\u0435\u043b. \u0412 SHA256 <code>h<\/code> \u0445\u0440\u0430\u043d\u0438\u0442 32 \u0431\u0438\u0442\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0430 \u0432 SHA512 64 \u0431\u0438\u0442\u0430.<\/p>\n<p>\u041f\u043e\u0445\u043e\u0436\u0438\u0439 \u0441\u043c\u044b\u0441\u043b \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d \u0432 <code>K<\/code>. \u0412 \u044d\u0442\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0442\u043e\u0436\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u0440\u043e\u0431\u043d\u044b\u0445 \u0447\u0430\u0441\u0442\u0435\u0439, \u043d\u043e \u0443\u0436\u0435 \u043a\u0443\u0431\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043a\u043e\u0440\u043d\u0435\u0439 \u043e\u0442 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0447\u0438\u0441\u0435\u043b. \u0412 SHA256 <code>K<\/code> \u0445\u0440\u0430\u043d\u0438\u0442 64 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e 32 \u0431\u0438\u0442\u0430, \u0430 \u0432 SHA512 80 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u043e 64 \u0431\u0438\u0442\u0430.<\/p>\n<h2>\u0428\u0430\u0433 3 &#8212; \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043b\u043e\u0432<\/h2>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u0430\u043f, \u0433\u0434\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0431\u043b\u043e\u043a \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0412 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0431\u043b\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0432 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438. \u0412 \u0431\u043b\u043e\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0431\u0430\u0439\u0442\u0430\u043c\u0438 (8 \u0431\u0438\u0442), \u0430 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 <code>h<\/code> \u0438 <code>K<\/code> 32-\u0445 \u0431\u0438\u0442\u043d\u044b\u0435 \u0438 64-\u0445 \u0431\u0438\u0442\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 &#8212; \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0431\u0430\u0439\u0442\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0441\u043b\u043e\u0432\u0430 <code>w<\/code>.<\/p>\n<p>SHA256:<\/p>\n<pre><code class=\"rust\">for block in blocks {     let mut w: Vec&lt;u32> = block.chunks_exact(4).map(|chunk| {         u32::from_be_bytes([chunk[0], chunk[1], chunk[2], chunk[3]])     }).collect();     w.append(&amp;mut vec![0u32; 48]);<\/code><\/pre>\n<p>SHA512:<\/p>\n<pre><code class=\"rust\">for block in blocks {     let mut w: Vec&lt;u64> = block.chunks_exact(8).map(|chunk| {         u64::from_be_bytes([chunk[0], chunk[1], chunk[2], chunk[3], chunk[4], chunk[5], chunk[6], chunk[7]])     }).collect();     w.append(&amp;mut vec![0u64; 64]);<\/code><\/pre>\n<p>\u0418\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e 16 \u0441\u043b\u043e\u0432, \u043d\u043e \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0442\u043e\u043b\u044c\u043a\u043e, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0440\u0430\u0443\u043d\u0434\u043e\u0432\u044b\u0445 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442. \u041c\u044b \u0441\u0440\u0430\u0437\u0443 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u0432\u0435\u043a\u0442\u043e\u0440 \u043d\u0443\u043b\u0435\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0438\u0445 \u043d\u0430 \u0441\u043b\u043e\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u043c \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<p>SHA256:<\/p>\n<pre><code class=\"rust\">for i in 16..64 {     let s0 = (w[i - 15].rotate_right(7)) ^ (w[i - 15].rotate_right(18)) ^ (w[i - 15] >> 3);     let s1 = (w[i - 2].rotate_right(17)) ^ (w[i - 2].rotate_right(19)) ^ (w[i - 2] >> 10);     w[i] = w[i - 16].wrapping_add(s0).wrapping_add(w[i - 7]).wrapping_add(s1); }<\/code><\/pre>\n<p>SHA512:<\/p>\n<pre><code class=\"rust\">for i in 16..80 {     let s0 = (w[i - 15].rotate_right(1)) ^ (w[i - 15].rotate_right(8)) ^ (w[i - 15] >> 7);     let s1 = (w[i - 2].rotate_right(19)) ^ (w[i - 2].rotate_right(61)) ^ (w[i - 2] >> 6);     w[i] = w[i - 16].wrapping_add(s0).wrapping_add(w[i - 7]).wrapping_add(s1); }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0441\u0434\u0432\u0438\u0433\u0438, \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0441\u0434\u0432\u0438\u0433\u0438 \u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0435\u0433\u043e \u0418\u041b\u0418. \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043b\u043e\u0432\u043e, \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u0438 \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 <code>Rust<\/code> \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <code>wrapping_add()<\/code>.<\/p>\n<h2>\u0428\u0430\u0433 4 &#8212; \u0441\u0436\u0430\u0442\u0438\u0435<\/h2>\n<p>\u041d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u043e \u0431\u043b\u043e\u043a\u0430\u043c, \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>tmp_h<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 <code>h<\/code>. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0432\u043d\u043e\u0441\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 <code>tmp_h<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0445\u044d\u0448.<\/p>\n<p>SHA256:<\/p>\n<pre><code class=\"rust\">let mut tmp_h: [u32; 8] = h.clone();<\/code><\/pre>\n<p>SHA512:<\/p>\n<pre><code class=\"rust\">let mut tmp_h: [u64; 8] = h.clone();<\/code><\/pre>\n<p>\u0412\u0441\u0435 \u043f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u044b, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a \u0440\u0430\u0443\u043d\u0434\u0430\u043c \u0445\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0443\u043d\u0434\u043e\u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0440\u0430\u0443\u043d\u0434\u043e\u0432\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 <code>k<\/code>.<\/p>\n<p>SHA256:<\/p>\n<pre><code class=\"rust\">for i in 0..64 {     let s1 = (tmp_h[4].rotate_right(6)) ^ (tmp_h[4].rotate_right(11)) ^ (tmp_h[4].rotate_right(25));     let ch = (tmp_h[4] &amp; tmp_h[5]) ^ (!tmp_h[4] &amp; tmp_h[6]);     let temp1 = tmp_h[7].wrapping_add(s1).wrapping_add(ch).wrapping_add(K[i]).wrapping_add(w[i]);     let s0 = (tmp_h[0].rotate_right(2)) ^ (tmp_h[0].rotate_right(13)) ^ (tmp_h[0].rotate_right(22));     let maj = (tmp_h[0] &amp; tmp_h[1]) ^ (tmp_h[0] &amp; tmp_h[2]) ^ (tmp_h[1] &amp; tmp_h[2]);     let temp2 = s0.wrapping_add(maj);<\/code><\/pre>\n<p>SHA512:<\/p>\n<pre><code class=\"rust\">for i in 0..80 {     let s1 = (tmp_h[4].rotate_right(14)) ^ (tmp_h[4].rotate_right(18)) ^ (tmp_h[4].rotate_right(41));     let ch = (tmp_h[4] &amp; tmp_h[5]) ^ (!tmp_h[4] &amp; tmp_h[6]);     let temp1 = tmp_h[7].wrapping_add(s1).wrapping_add(ch).wrapping_add(K[i]).wrapping_add(w[i]);     let s0 = (tmp_h[0].rotate_right(28)) ^ (tmp_h[0].rotate_right(34)) ^ (tmp_h[0].rotate_right(39));     let maj = (tmp_h[0] &amp; tmp_h[1]) ^ (tmp_h[0] &amp; tmp_h[2]) ^ (tmp_h[1] &amp; tmp_h[2]);     let temp2 = s0.wrapping_add(maj);<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438: \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u0442\u0440\u0438\u0446\u0430\u043d\u0438\u0435 \u0438 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0418. \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u0441\u0430\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0443 \u043e\u0431\u043e\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 SHA256 \u0438 SHA512 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b, \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u0434\u0432\u0438\u0433\u043e\u0432.<\/p>\n<p>\u041d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0430\u0443\u043d\u0434\u0435 \u043c\u044b \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <code>tmp_h<\/code>.<\/p>\n<p>SHA256 \u0438 SHA512:<\/p>\n<pre><code class=\"rust\">tmp_h[7] = tmp_h[6]; tmp_h[6] = tmp_h[5]; tmp_h[5] = tmp_h[4]; tmp_h[4] = tmp_h[3].wrapping_add(temp1); tmp_h[3] = tmp_h[2]; tmp_h[2] = tmp_h[1]; tmp_h[1] = tmp_h[0]; tmp_h[0] = temp1.wrapping_add(temp2);<\/code><\/pre>\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/companies\/selectel\/articles\/530262\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u0435<\/a>, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u0441\u0441\u044b\u043b\u0430\u043b\u0441\u044f \u0432\u044b\u0448\u0435 \u0434\u043e\u043f\u0443\u0449\u0435\u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0430. \u041f\u043e \u0441\u0443\u0442\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0431\u044b\u043b\u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e <code>f = e<\/code>, \u043d\u043e \u0432 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0438 \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u0435\u0441\u0442\u044c.<\/p>\n<h2>\u0428\u0430\u0433 5 &#8212; \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0445\u044d\u0448\u0430<\/h2>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0432\u0441\u0435\u0445 \u0440\u0430\u0443\u043d\u0434\u043e\u0432 \u0445\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <code>h<\/code> \u0438 <code>tmp_h<\/code>.<\/p>\n<p>SHA256 \u0438 SHA512:<\/p>\n<pre><code class=\"rust\">for i in 0..8 {     h[i] = h[i].wrapping_add(tmp_h[i]); }<\/code><\/pre>\n<p>\u0428\u0430\u0433\u0438 3, 4 \u0438 5 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0431\u043b\u043e\u043a\u043e\u0432, \u043d\u0438 \u043e\u0434\u0438\u043d \u0431\u0430\u0439\u0442 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0431\u0435\u0437 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f.<\/p>\n<h2>\u0428\u0430\u0433 6 &#8212; \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0445\u044d\u0448\u0430<\/h2>\n<p>\u0412 \u043a\u043e\u043d\u0446\u0435 <code>h<\/code> \u0445\u0440\u0430\u043d\u0438\u0442 \u0431\u0430\u0439\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u043c\u0438 \u0445\u044d\u0448\u0430. \u0427\u0430\u0441\u0442\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0439 \u0432\u0438\u0434.<\/p>\n<p>SHA256:<\/p>\n<pre><code class=\"rust\">h.iter() .map(|byte| format!(\"{:08x}\", byte)) .collect::&lt;Vec&lt;String>>() .join(\"\")<\/code><\/pre>\n<p>SHA512:<\/p>\n<pre><code class=\"rust\">h.iter() .map(|byte| format!(\"{:016x}\", byte)) .collect::&lt;Vec&lt;String>>() .join(\"\")<\/code><\/pre>\n<h2>\u0420\u0435\u043c\u0430\u0440\u043a\u0430<\/h2>\n<p>\u0415\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0441\u0442, \u0433\u0434\u0435 \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0433\u0434\u0435-\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. \u042d\u0442\u0430 \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u0434\u043b\u044f \u043d\u043e\u0432\u0438\u0447\u043a\u043e\u0432, \u043b\u044e\u0434\u0438 \u043f\u043e-\u043e\u043f\u044b\u0442\u043d\u0435\u0435 \u043c\u043e\u0433\u0443\u0442 \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c.<\/p>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0431\u044b\u043b \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u0441 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u0430 \u0432\u044b\u0432\u043e\u0434 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 <code>sha256sum<\/code> \u0438 <code>sha512sum<\/code> \u0438\u0437 \u043f\u0430\u043a\u0435\u0442\u0430 <code>coreutils<\/code> \u0432\u0435\u0440\u0441\u0438\u0438 9.5.<\/p>\n<ol>\n<li>\n<p>\u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435, \u0447\u0442\u043e \u0437\u043d\u0430\u043a \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 \u0442\u043e\u0436\u0435 \u0437\u043d\u0430\u043a. \u041e\u043d \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u0435 \u0431\u0430\u0439\u0442\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0445\u044d\u0448. <code>\"hello world\"<\/code> \u0438 <code>\"hello world\\n\"<\/code> &#8212; \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u0434\u0430\u0434\u0443\u0442 \u0440\u0430\u0437\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0445\u044d\u0448\u0430.<br \/>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>echo \"hello world\" | sha256sum<\/code> \u0432\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0435 \u0432 \u0443\u0442\u0438\u043b\u0438\u0442\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 <code>\"hello world\\n\"<\/code> , \u0442\u043e \u0435\u0441\u0442\u044c \u0441 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u043e\u043c \u0441\u0442\u0440\u043e\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u044b\u0435 \u0432\u0435\u0434\u0443\u0449\u0438\u0435 \u043d\u0443\u043b\u0438. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f <code>0x03<\/code> \u0438 <code>0x3<\/code> \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043e\u0434\u043d\u0430\u043a\u043e \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0435 \u0445\u044d\u0448 \u0447\u0435\u0440\u0435\u0437 \u0441\u0432\u043e\u044e \u0443\u0442\u0438\u043b\u0438\u0442\u0443 \u0438 \u0437\u0430\u0431\u0443\u0434\u0435\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u044b\u0435 \u043d\u0443\u043b\u0438, \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0445\u044d\u0448\u0430 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u0441\u044f \u043d\u0435\u0443\u0434\u0430\u0447\u0435\u0439.<\/p>\n<\/li>\n<\/ol>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041f\u0438\u0448\u0443 \u0441\u0442\u0430\u0442\u044c\u044e \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0433\u0434\u0435-\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043d\u0435\u0442\u043e\u0447\u043d\u043e \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u043d\u0435\u0432\u0435\u0440\u043d\u043e. \u041f\u043e\u0434\u0430\u0447\u0430 \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043a\u0443\u0446\u0435\u0439, \u043e\u0434\u043d\u0430\u043a\u043e \u044f \u043d\u0435 \u0445\u043e\u0442\u0435\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043f\u043e SHA256\/SHA512. \u0427\u0442\u043e\u0431\u044b \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u044d\u0442\u0438\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c \u0432\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0447\u0435\u0441\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430, \u0430 \u0437\u0434\u0435\u0441\u044c \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0437\u0430\u043c\u0435\u0442\u043a\u0430 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0442\u0443\u043f\u0438\u043b \u0432 \u043f\u0430\u0440\u0435 \u043c\u0435\u0441\u0442 \u0438 \u0440\u0435\u0448\u0438\u043b \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043c\u043e\u0447\u044c \u0434\u0440\u0443\u0433\u0438\u043c.<\/p>\n<p>\u041b\u044e\u0431\u044b\u0435 \u043f\u0440\u0430\u0432\u043a\u0438, \u0441\u043e\u0432\u0435\u0442\u044b, \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0433\u043e\u0442\u043e\u0432 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0438 \u0432\u043d\u0435\u0441\u0442\u0438 \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u0430\u043a \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445, \u0442\u0430\u043a \u0438 \u0432 <a href=\"https:\/\/gitverse.ru\/digit4lsh4d0w\/cryptography\/content\/main\/hand-made-sha\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/a>.<\/p>\n<p>\u0415\u0449\u0435 \u0431\u044b \u044f \u0445\u043e\u0442\u0435\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u043e \u0445\u044d\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0421\u0442\u0440\u0438\u0431\u043e\u0433 (\u0413\u041e\u0421\u0422 \u0420 34.11-2012). \u041d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 (\u0438\u043b\u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0440\u0435\u0430\u043a\u0446\u0438\u0438) \u0435\u0441\u043b\u0438 \u0431\u044b \u0445\u043e\u0442\u0435\u043b\u0438 \u0442\u0430\u043a\u043e\u0439 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/811639\/\"> https:\/\/habr.com\/ru\/articles\/811639\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><\/figure>\n<p>\u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e \u043c\u0435\u043d\u044f \u043f\u043e\u0431\u0443\u0434\u0438\u043b\u0438 2 \u0432\u0435\u0449\u0438:<\/p>\n<ol>\n<li>\n<p>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 \u0432 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0438\u0442\u0435\u0442\u0435<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/companies\/selectel\/articles\/530262\/\" rel=\"noopener noreferrer nofollow\">\u0421\u043b\u0430\u0431\u044b\u0439 \u043f\u0435\u0440\u0435\u0441\u043a\u0430\u0437<\/a> \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 SHA256.<\/p>\n<\/li>\n<\/ol>\n<p>\u042f \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u043f\u0440\u043e\u0431\u0435\u043b\u044b \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0441\u0432\u043e\u0438\u043c\u0438 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u044f\u043c\u0438 \u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u043a\u043e\u0434\u0430 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 Rust. \u0411\u0443\u0434\u0443\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0434\u043b\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 SHA256 \u0438 SHA512. \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u043c \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u0430\u043c. \u0411\u043e\u043b\u0435\u0435 \u043e\u043f\u044b\u0442\u043d\u044b\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442\u0441\u044f. <\/p>\n<p>\u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d \u0432 <a href=\"https:\/\/gitverse.ru\/digit4lsh4d0w\/cryptography\/content\/main\/hand-made-sha\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 GitVerse<\/a>.<\/p>\n<h2>\u0428\u0430\u0433 1 &#8212; \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 \u0431\u043b\u043e\u043a\u0438<\/h2>\n<p>\u041d\u0430 \u0432\u0445\u043e\u0434 \u0445\u044d\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0434\u0430\u044e\u0442\u0441\u044f \u0431\u0430\u0439\u0442\u044b \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f. \u0425\u0430\u0440\u0430\u043a\u0442\u0435\u0440 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043d\u0430\u043c \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u0438 \u043d\u0435\u0432\u0430\u0436\u0435\u043d, \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0447\u0442\u043e-\u0443\u0433\u043e\u0434\u043d\u043e &#8212; \u0442\u0435\u043a\u0441\u0442, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0430\u0443\u0434\u0438\u043e \u0444\u0430\u0439\u043b. \u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0444\u043e\u0440\u043c\u0438\u0442\u044c \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0438\u043c\u0438.<\/p>\n<p>\u0418\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u044b \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0431\u043b\u043e\u043a\u0438, \u0434\u043b\u044f SHA256 \u0440\u0430\u0437\u043c\u0435\u0440 \u0431\u043b\u043e\u043a\u0430 \u0440\u0430\u0432\u0435\u043d 64 \u0431\u0430\u0439\u0442\u0430\u043c (512 \u0431\u0438\u0442), \u0430 \u0434\u043b\u044f SHA512 128 \u0431\u0430\u0439\u0442 (1024 \u0431\u0438\u0442\u0430). \u0414\u0430\u043d\u043d\u044b\u0435 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0438\u043c\u0435\u044e\u0442 \u043d\u0435 \u043a\u0440\u0430\u0442\u043d\u044b\u0439 \u0431\u043b\u043e\u043a\u0430\u043c \u0440\u0430\u0437\u043c\u0435\u0440, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0445 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u0442\u044c. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0435\u0434\u0438\u043d:<\/p>\n<ol>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044e \u0431\u0430\u0439\u0442 <code>0x80<\/code>. \u0412 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u043c \u0432\u0438\u0434\u0435 <code>0x80<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a <code>10000000<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044e \u043d\u0443\u043b\u0435\u0432\u044b\u0435 \u0431\u0430\u0439\u0442\u044b <code>0x00<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044e \u0432\u043e\u0441\u0435\u043c\u044c \u0431\u0430\u0439\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u0438\u043d\u044b \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u043d\u0435\u0441\u0435\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u0438\u043a\u0443. \u0421\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0431\u0430\u0439\u0442\u0430 <code>0x80<\/code> \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u043d\u0443\u043b\u0435\u0432\u044b\u043c\u0438 \u0431\u0430\u0439\u0442\u0430\u043c\u0438 <code>0x00<\/code>. \u042d\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0444\u043e\u0440\u043c\u0443\u043b\u043e\u0439:<\/p>\n<p>\u0413\u0434\u0435 <code>x<\/code> &#8212; \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0443\u043b\u0435\u0439 \u0434\u043b\u044f \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, <code>b<\/code> &#8212; \u0440\u0430\u0437\u043c\u0435\u0440 \u0431\u043b\u043e\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, <code>m<\/code> &#8212; \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u041c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0442\u043e\u0447\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0443\u043b\u0435\u0439 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c \u0431\u043b\u043e\u043a\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b\u0447\u0438\u0442\u0430\u0435\u043c \u0438\u0437 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0431\u043b\u043e\u043a\u0430 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u0431\u043b\u043e\u043a\u0430. \u041d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u0431\u044b\u0432\u0430\u0442\u044c \u0438 \u043f\u0440\u043e \u0431\u0430\u0439\u0442 <code>0x80<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c 8 \u0431\u0430\u0439\u0442 (64 \u0431\u0438\u0442\u0430) \u0434\u043b\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u0438\u043d\u044b \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u0431\u043b\u043e\u043a\u0430 \u0434\u043b\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 SHA256<\/figcaption><\/div>\n<\/figure>\n<p>\u041c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0442\u0430\u043a\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f, \u0447\u0442\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u0438\u043d\u044b \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0441\u0442\u0430 \u043d\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0411\u043b\u043e\u043a, \u0433\u0434\u0435 \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 \u043c\u0435\u0441\u0442\u043e \u0437\u0430\u043d\u044f\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u043c\u0438<\/figcaption><\/div>\n<\/figure>\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/companies\/selectel\/articles\/530262\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u0435<\/a>, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u0441\u0441\u044b\u043b\u0430\u043b\u0441\u044f \u0432\u044b\u0448\u0435, \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u0443\u043f\u0443\u0449\u0435\u043d. \u041e\u0434\u043d\u0430\u043a\u043e \u043d\u0430 \u0412\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u0438 \u0432\u0441\u0435 \u044f\u0441\u043d\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u043e. \u041c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0431\u0430\u0439\u0442 <code>0x80<\/code> \u0438 \u043e\u0441\u0442\u0430\u0432\u0448\u0435\u0435\u0441\u044f \u043c\u0435\u0441\u0442\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043d\u0443\u043b\u044f\u043c\u0438. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u0431\u043b\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0443\u043b\u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044f \u0438 8 \u0431\u0430\u0439\u0442 (64 \u0431\u0438\u0442\u0430) \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u0438\u043d\u044b \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0414\u0432\u0430 \u0431\u043b\u043e\u043a\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 SHA256<\/figcaption><\/div>\n<\/figure>\n<p>SHA256:<\/p>\n<pre><code class=\"rust\">pub fn sha256(message: &amp;[u8]) -> String {     let mut m = message.to_vec();     m.push(0x80);     if 64 - m.len() % 64 &lt; 8 {         m.append(&amp;mut vec![0u8; 64 - m.len() % 64])     }     m.append(&amp;mut vec![0u8; 64 - m.len() % 64 - 8]);     m.append(&amp;mut (message.len() as u64 * 8).to_be_bytes().to_vec());     let blocks = m.chunks_exact(64);<\/code><\/pre>\n<p>SHA512:<\/p>\n<pre><code class=\"rust\">pub fn sha512(message: &amp;[u8]) -> String {     let mut m = message.to_vec();     m.push(0x80);     if 128 - m.len() % 128 &lt; 8 {         m.append(&amp;mut vec![0u8; 128 - m.len() % 128])     }     m.append(&amp;mut vec![0u8; 128 - m.len() % 128 - 8]);     m.append(&amp;mut (message.len() as u64 * 8).to_be_bytes().to_vec());     let blocks = m.chunks_exact(128);<\/code><\/pre>\n<p>\u041e\u0442\u043b\u0438\u0447\u0438\u0435 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 SHA512 \u0440\u0430\u0437\u043c\u0435\u0440 \u0431\u043b\u043e\u043a \u0432\u0434\u0432\u043e\u0435 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u0443 SHA256, \u0442\u043e \u0435\u0441\u0442\u044c 128 \u0431\u0430\u0439\u0442 (1024 \u0431\u0438\u0442\u0430).<\/p>\n<h2>\u0428\u0430\u0433 2 &#8212; \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439<\/h2>\n<p>\u041c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0432\u0435 \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435. \u041e\u0434\u043d\u0430 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>h<\/code> \u0438 \u0445\u0440\u0430\u043d\u0438\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0448\u0430\u0433\u0430\u0445, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a\u0430\u043a \u0440\u0430\u0437 \u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u0445\u044d\u0448\u0430, \u0430 \u0434\u0440\u0443\u0433\u0430\u044f \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>K<\/code> \u0438 \u0445\u0440\u0430\u043d\u0438\u0442 \u0440\u0430\u0443\u043d\u0434\u043e\u0432\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0441\u0436\u0430\u0442\u0438\u044f.<\/p>\n<p>SHA256:<\/p>\n<pre><code class=\"rust\">let mut h: [u32; 8] = [     0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,     0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19, ]; const K: [u32; 64] = [     0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,     0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,     0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,     0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,     0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,     0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,     0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,     0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,     0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,     0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,     0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,     0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,     0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,     0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,     0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,     0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2, ];<\/code><\/pre>\n<p>SHA512:<\/p>\n<pre><code class=\"rust\">let mut h: [u64; 8] = [     0x6a09e667f3bcc908, 0xbb67ae8584caa73b, 0x3c6ef372fe94f82b, 0xa54ff53a5f1d36f1,     0x510e527fade682d1, 0x9b05688c2b3e6c1f, 0x1f83d9abfb41bd6b, 0x5be0cd19137e2179, ]; const K: [u64; 80] = [     0x428a2f98d728ae22, 0x7137449123ef65cd, 0xb5c0fbcfec4d3b2f, 0xe9b5dba58189dbbc,     0x3956c25bf348b538, 0x59f111f1b605d019, 0x923f82a4af194f9b, 0xab1c5ed5da6d8118,     0xd807aa98a3030242, 0x12835b0145706fbe, 0x243185be4ee4b28c, 0x550c7dc3d5ffb4e2,     0x72be5d74f27b896f, 0x80deb1fe3b1696b1, 0x9bdc06a725c71235, 0xc19bf174cf692694,     0xe49b69c19ef14ad2, 0xefbe4786384f25e3, 0x0fc19dc68b8cd5b5, 0x240ca1cc77ac9c65,     0x2de92c6f592b0275, 0x4a7484aa6ea6e483, 0x5cb0a9dcbd41fbd4, 0x76f988da831153b5,     0x983e5152ee66dfab, 0xa831c66d2db43210, 0xb00327c898fb213f, 0xbf597fc7beef0ee4,     0xc6e00bf33da88fc2, 0xd5a79147930aa725, 0x06ca6351e003826f, 0x142929670a0e6e70,     0x27b70a8546d22ffc, 0x2e1b21385c26c926, 0x4d2c6dfc5ac42aed, 0x53380d139d95b3df,     0x650a73548baf63de, 0x766a0abb3c77b2a8, 0x81c2c92e47edaee6, 0x92722c851482353b,     0xa2bfe8a14cf10364, 0xa81a664bbc423001, 0xc24b8b70d0f89791, 0xc76c51a30654be30,     0xd192e819d6ef5218, 0xd69906245565a910, 0xf40e35855771202a, 0x106aa07032bbd1b8,     0x19a4c116b8d2d0c8, 0x1e376c085141ab53, 0x2748774cdf8eeb99, 0x34b0bcb5e19b48a8,     0x391c0cb3c5c95a63, 0x4ed8aa4ae3418acb, 0x5b9cca4f7763e373, 0x682e6ff3d6b2b8a3,     0x748f82ee5defb2fc, 0x78a5636f43172f60, 0x84c87814a1f0ab72, 0x8cc702081a6439ec,     0x90befffa23631e28, 0xa4506cebde82bde9, 0xbef9a3f7b2c67915, 0xc67178f2e372532b,     0xca273eceea26619c, 0xd186b8c721c0c207, 0xeada7dd6cde0eb1e, 0xf57d4f7fee6ed178,     0x06f067aa72176fba, 0x0a637dc5a2c898a6, 0x113f9804bef90dae, 0x1b710b35131c471b,     0x28db77f523047d84, 0x32caab7b40c72493, 0x3c9ebe0a15c9bebc, 0x431d67c49c100d4c,     0x4cc5d4becb3e42b6, 0x597f299cfc657e2a, 0x5fcb6fab3ad6faec, 0x6c44198c4a475817, ];<\/code><\/pre>\n<p><code>h<\/code> \u0445\u0440\u0430\u043d\u0438\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u0440\u043e\u0431\u043d\u044b\u0445 \u0447\u0430\u0441\u0442\u0435\u0439 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0445 \u043a\u043e\u0440\u043d\u0435\u0439 \u043e\u0442 \u043f\u0435\u0440\u0432\u044b\u0445 \u0432\u043e\u0441\u044c\u043c\u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0447\u0438\u0441\u0435\u043b. \u0412 SHA256 <code>h<\/code> \u0445\u0440\u0430\u043d\u0438\u0442 32 \u0431\u0438\u0442\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0430 \u0432 SHA512 64 \u0431\u0438\u0442\u0430.<\/p>\n<p>\u041f\u043e\u0445\u043e\u0436\u0438\u0439 \u0441\u043c\u044b\u0441\u043b \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d \u0432 <code>K<\/code>. \u0412 \u044d\u0442\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0442\u043e\u0436\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u0440\u043e\u0431\u043d\u044b\u0445 \u0447\u0430\u0441\u0442\u0435\u0439, \u043d\u043e \u0443\u0436\u0435 \u043a\u0443\u0431\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043a\u043e\u0440\u043d\u0435\u0439 \u043e\u0442 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0447\u0438\u0441\u0435\u043b. \u0412 SHA256 <code>K<\/code> \u0445\u0440\u0430\u043d\u0438\u0442 64 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e 32 \u0431\u0438\u0442\u0430, \u0430 \u0432 SHA512 80 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u043e 64 \u0431\u0438\u0442\u0430.<\/p>\n<h2>\u0428\u0430\u0433 3 &#8212; \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043b\u043e\u0432<\/h2>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u0430\u043f, \u0433\u0434\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0431\u043b\u043e\u043a \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0412 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0431\u043b\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0432 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438. \u0412 \u0431\u043b\u043e\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0431\u0430\u0439\u0442\u0430\u043c\u0438 (8 \u0431\u0438\u0442), \u0430 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 <code>h<\/code> \u0438 <code>K<\/code> 32-\u0445 \u0431\u0438\u0442\u043d\u044b\u0435 \u0438 64-\u0445 \u0431\u0438\u0442\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 &#8212; \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0431\u0430\u0439\u0442\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0441\u043b\u043e\u0432\u0430 <code>w<\/code>.<\/p>\n<p>SHA256:<\/p>\n<pre><code class=\"rust\">for block in blocks {     let mut w: Vec&lt;u32> = block.chunks_exact(4).map(|chunk| {         u32::from_be_bytes([chunk[0], chunk[1], chunk[2], chunk[3]])     }).collect();     w.append(&amp;mut vec![0u32; 48]);<\/code><\/pre>\n<p>SHA512:<\/p>\n<pre><code class=\"rust\">for block in blocks {     let mut w: Vec&lt;u64> = block.chunks_exact(8).map(|chunk| {         u64::from_be_bytes([chunk[0], chunk[1], chunk[2], chunk[3], chunk[4], chunk[5], chunk[6], chunk[7]])     }).collect();     w.append(&amp;mut vec![0u64; 64]);<\/code><\/pre>\n<p>\u0418\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e 16 \u0441\u043b\u043e\u0432, \u043d\u043e \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0442\u043e\u043b\u044c\u043a\u043e, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0440\u0430\u0443\u043d\u0434\u043e\u0432\u044b\u0445 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442. \u041c\u044b \u0441\u0440\u0430\u0437\u0443 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u0432\u0435\u043a\u0442\u043e\u0440 \u043d\u0443\u043b\u0435\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0438\u0445 \u043d\u0430 \u0441\u043b\u043e\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u043c \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<p>SHA256:<\/p>\n<pre><code class=\"rust\">for i in 16..64 {     let s0 = (w[i - 15].rotate_right(7)) ^ (w[i - 15].rotate_right(18)) ^ (w[i - 15] >> 3);     let s1 = (w[i - 2].rotate_right(17)) ^ (w[i - 2].rotate_right(19)) ^ (w[i - 2] >> 10);     w[i] = w[i - 16].wrapping_add(s0).wrapping_add(w[i - 7]).wrapping_add(s1); }<\/code><\/pre>\n<p>SHA512:<\/p>\n<pre><code class=\"rust\">for i in 16..80 {     let s0 = (w[i - 15].rotate_right(1)) ^ (w[i - 15].rotate_right(8)) ^ (w[i - 15] >> 7);     let s1 = (w[i - 2].rotate_right(19)) ^ (w[i - 2].rotate_right(61)) ^ (w[i - 2] >> 6);     w[i] = w[i - 16].wrapping_add(s0).wrapping_add(w[i - 7]).wrapping_add(s1); }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0441\u0434\u0432\u0438\u0433\u0438, \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0441\u0434\u0432\u0438\u0433\u0438 \u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0435\u0433\u043e \u0418\u041b\u0418. \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043b\u043e\u0432\u043e, \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u0438 \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 <code>Rust<\/code> \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <code>wrapping_add()<\/code>.<\/p>\n<h2>\u0428\u0430\u0433 4 &#8212; \u0441\u0436\u0430\u0442\u0438\u0435<\/h2>\n<p>\u041d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u043e \u0431\u043b\u043e\u043a\u0430\u043c, \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>tmp_h<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 <code>h<\/code>. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0432\u043d\u043e\u0441\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 <code>tmp_h<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0445\u044d\u0448.<\/p>\n<p>SHA256:<\/p>\n<pre><code class=\"rust\">let mut tmp_h: [u32; 8] = h.clone();<\/code><\/pre>\n<p>SHA512:<\/p>\n<pre><code class=\"rust\">let mut tmp_h: [u64; 8] = h.clone();<\/code><\/pre>\n<p>\u0412\u0441\u0435 \u043f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u044b, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a \u0440\u0430\u0443\u043d\u0434\u0430\u043c \u0445\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0443\u043d\u0434\u043e\u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0440\u0430\u0443\u043d\u0434\u043e\u0432\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 <code>k<\/code>.<\/p>\n<p>SHA256:<\/p>\n<pre><code class=\"rust\">for i in 0..64 {     let s1 = (tmp_h[4].rotate_right(6)) ^ (tmp_h[4].rotate_right(11)) ^ (tmp_h[4].rotate_right(25));     let ch = (tmp_h[4] &amp; tmp_h[5]) ^ (!tmp_h[4] &amp; tmp_h[6]);     let temp1 = tmp_h[7].wrapping_add(s1).wrapping_add(ch).wrapping_add(K[i]).wrapping_add(w[i]);     let s0 = (tmp_h[0].rotate_right(2)) ^ (tmp_h[0].rotate_right(13)) ^ (tmp_h[0].rotate_right(22));     let maj = (tmp_h[0] &amp; tmp_h[1]) ^ (tmp_h[0] &amp; tmp_h[2]) ^ (tmp_h[1] &amp; tmp_h[2]);     let temp2 = s0.wrapping_add(maj);<\/code><\/pre>\n<p>SHA512:<\/p>\n<pre><code class=\"rust\">for i in 0..80 {     let s1 = (tmp_h[4].rotate_right(14)) ^ (tmp_h[4].rotate_right(18)) ^ (tmp_h[4].rotate_right(41));     let ch = (tmp_h[4] &amp; tmp_h[5]) ^ (!tmp_h[4] &amp; tmp_h[6]);     let temp1 = tmp_h[7].wrapping_add(s1).wrapping_add(ch).wrapping_add(K[i]).wrapping_add(w[i]);     let s0 = (tmp_h[0].rotate_right(28)) ^ (tmp_h[0].rotate_right(34)) ^ (tmp_h[0].rotate_right(39));     let maj = (tmp_h[0] &amp; tmp_h[1]) ^ (tmp_h[0] &amp; tmp_h[2]) ^ (tmp_h[1] &amp; tmp_h[2]);     let temp2 = s0.wrapping_add(maj);<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438: \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u0442\u0440\u0438\u0446\u0430\u043d\u0438\u0435 \u0438 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0418. \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u0441\u0430\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0443 \u043e\u0431\u043e\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 SHA256 \u0438 SHA512 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b, \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u0434\u0432\u0438\u0433\u043e\u0432.<\/p>\n<p>\u041d\u0430 <\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-375156","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/375156","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=375156"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/375156\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=375156"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=375156"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=375156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}