{"id":2296,"date":"2017-11-02T10:35:30","date_gmt":"2017-11-02T02:35:30","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=2296"},"modified":"2017-11-02T10:35:30","modified_gmt":"2017-11-02T02:35:30","slug":"%e5%8f%8c%e5%9b%a0%e7%b4%a0%e8%ae%a4%e8%af%81%ef%bc%882fa%ef%bc%89%e6%96%b9%e6%a1%88totp-%e7%9a%84%e7%ae%97%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=2296","title":{"rendered":"\u53cc\u56e0\u7d20\u8ba4\u8bc1\uff082FA\uff09\u65b9\u6848TOTP \u7684\u7b97\u6cd5"},"content":{"rendered":"<p>\n\t\u57fa\u4e8e\u65f6\u95f4\u7684\u4e00\u6b21\u6027\u5bc6\u7801\u7b97\u6cd5\uff08TOTP\uff09\u662f\u4e00\u4e2a\u7b97\u6cd5\uff0c\u8ba1\u7b97\u51fa\u4e00\u4e2a\u4e00\u6b21\u6027\u5bc6\u7801\uff0c\u4ece\u4e00\u4e2a\u5171\u4eab\u5bc6\u94a5\u548c\u5f53\u524d\u65f6\u95f4\u3002\u5b83\u5df2\u88ab\u91c7\u7eb3\u4e3a\u56e0\u7279\u7f51\u5de5\u7a0b\u5de5\u4f5c\u961f\u6807\u51c6<a href=\"https:\/\/tools.ietf.org\/html\/rfc6238\" name=\"TOTP: Time-Based One-Time Password Algorithm\" target=\"_blank\" title=\"TOTP: Time-Based One-Time Password Algorithm\">RFC 6238<\/a>\uff0c\u5b83\u662f\u5f00\u653e\u5f0f\u8ba4\u8bc1\uff08\u5ba3\u8a93\uff09\u4e3b\u52a8\u6743\u7684\u57fa\u77f3\uff0c\u7528\u4e8e\u8bb8\u591a\u53cc\u56e0\u7d20\u8ba4\u8bc1\u7cfb\u7edf\u3002\n<\/p>\n<h2>\n\tTOTP \u7684\u6982\u5ff5<br \/>\n<\/h2>\n<p>\n\tTOTP \u7684\u5168\u79f0\u662f&quot;\u57fa\u4e8e\u65f6\u95f4\u7684\u4e00\u6b21\u6027\u5bc6\u7801&quot;\uff08Time-based One-time Password\uff09\u3002\u5b83\u662f\u516c\u8ba4\u7684\u53ef\u9760\u89e3\u51b3\u65b9\u6848\uff0c\u5df2\u7ecf\u5199\u5165\u56fd\u9645\u6807\u51c6&nbsp;<a href=\"https:\/\/tools.ietf.org\/html\/rfc6238\" target=\"_blank\">RFC6238<\/a>\u3002\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"\" src=\"http:\/\/www.ruanyifeng.com\/blogimg\/asset\/2017\/bg2017110106.jpg\" title=\"\" \/>\n<\/p>\n<p>\n\t\u5b83\u7684\u6b65\u9aa4\u5982\u4e0b\u3002\n<\/p>\n<p>\n\t\u7b2c\u4e00\u6b65\uff0c\u7528\u6237\u5f00\u542f\u53cc\u56e0\u7d20\u8ba4\u8bc1\u540e\uff0c\u670d\u52a1\u5668\u751f\u6210\u4e00\u4e2a\u5bc6\u94a5\u3002\n<\/p>\n<p>\n\t\u7b2c\u4e8c\u6b65\uff1a\u670d\u52a1\u5668\u63d0\u793a\u7528\u6237\u626b\u63cf\u4e8c\u7ef4\u7801\uff08\u6216\u8005\u4f7f\u7528\u5176\u4ed6\u65b9\u5f0f\uff09\uff0c\u628a\u5bc6\u94a5\u4fdd\u5b58\u5230\u7528\u6237\u7684\u624b\u673a\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u670d\u52a1\u5668\u548c\u7528\u6237\u7684\u624b\u673a\uff0c\u73b0\u5728\u90fd\u6709\u4e86\u540c\u4e00\u628a\u5bc6\u94a5\u3002\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"\" src=\"http:\/\/www.ruanyifeng.com\/blogimg\/asset\/2017\/bg2017110107.png\" title=\"\" \/>\n<\/p>\n<p>\n\t\u6ce8\u610f\uff0c\u5bc6\u94a5\u5fc5\u987b\u8ddf\u624b\u673a\u7ed1\u5b9a\u3002\u4e00\u65e6\u7528\u6237\u66f4\u6362\u624b\u673a\uff0c\u5c31\u5fc5\u987b\u751f\u6210\u5168\u65b0\u7684\u5bc6\u94a5\u3002\n<\/p>\n<p>\n\t\u7b2c\u4e09\u6b65\uff0c\u7528\u6237\u767b\u5f55\u65f6\uff0c\u624b\u673a\u5ba2\u6237\u7aef\u4f7f\u7528\u8fd9\u4e2a\u5bc6\u94a5\u548c\u5f53\u524d\u65f6\u95f4\u6233\uff0c\u751f\u6210\u4e00\u4e2a\u54c8\u5e0c\uff0c\u6709\u6548\u671f\u9ed8\u8ba4\u4e3a30\u79d2\u3002\u7528\u6237\u5728\u6709\u6548\u671f\u5185\uff0c\u628a\u8fd9\u4e2a\u54c8\u5e0c\u63d0\u4ea4\u7ed9\u670d\u52a1\u5668\u3002\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"\" src=\"http:\/\/www.ruanyifeng.com\/blogimg\/asset\/2017\/bg2017110108.jpg\" title=\"\" \/>\n<\/p>\n<p>\n\t\u7b2c\u56db\u6b65\uff0c\u670d\u52a1\u5668\u4e5f\u4f7f\u7528\u5bc6\u94a5\u548c\u5f53\u524d\u65f6\u95f4\u6233\uff0c\u751f\u6210\u4e00\u4e2a\u54c8\u5e0c\uff0c\u8ddf\u7528\u6237\u63d0\u4ea4\u7684\u54c8\u5e0c\u6bd4\u5bf9\u3002\u53ea\u8981\u4e24\u8005\u4e0d\u4e00\u81f4\uff0c\u5c31\u62d2\u7edd\u767b\u5f55\u3002\n<\/p>\n<h2>\n\tTOTP \u7684\u7b97\u6cd5<br \/>\n<\/h2>\n<p>\n\t\u4ed4\u7ec6\u770b\u4e0a\u9762\u7684\u6b65\u9aa4\uff0c\u4f60\u53ef\u80fd\u4f1a\u6709\u4e00\u4e2a\u95ee\u9898\uff1a\u624b\u673a\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\uff0c\u5982\u4f55\u4fdd\u8bc130\u79d2\u671f\u95f4\u90fd\u5f97\u5230\u540c\u4e00\u4e2a\u54c8\u5e0c\u5462\uff1f\n<\/p>\n<p>\n\t\u7b54\u6848\u5c31\u662f\u4e0b\u9762\u7684\u516c\u5f0f\u3002<code> <\/code>\n<\/p>\n<pre class=\"brush:plain;\">\r\nTC = floor((unixtime(now) &minus; unixtime(T0)) \/ TS)<\/pre>\n<p>\n\t\u4e0a\u9762\u7684\u516c\u5f0f\u4e2d\uff0cTC \u8868\u793a\u4e00\u4e2a\u65f6\u95f4\u8ba1\u6570\u5668\uff0c<code>unixtime(now)<\/code>\u662f\u5f53\u524d Unix \u65f6\u95f4\u6233\uff0c<code>unixtime(T0)<\/code>\u662f\u7ea6\u5b9a\u7684\u8d77\u59cb\u65f6\u95f4\u70b9\u7684\u65f6\u95f4\u6233\uff0c\u9ed8\u8ba4\u662f<code>0<\/code>\uff0c\u4e5f\u5c31\u662f1970\u5e741\u67081\u65e5\u3002TS \u5219\u662f\u54c8\u5e0c\u6709\u6548\u671f\u7684\u65f6\u95f4\u957f\u5ea6\uff0c\u9ed8\u8ba4\u662f30\u79d2\u3002\u56e0\u6b64\uff0c\u4e0a\u9762\u7684\u516c\u5f0f\u5c31\u53d8\u6210\u4e0b\u9762\u7684\u5f62\u5f0f\u3002<code> <\/code>\n<\/p>\n<pre class=\"brush:plain;\">\r\nTC = floor(unixtime(now) \/ 30)\r\n<\/pre>\n<p>\n\t\u6240\u4ee5\uff0c\u53ea\u8981\u5728 30 \u79d2\u4ee5\u5185\uff0cTC \u7684\u503c\u90fd\u662f\u4e00\u6837\u7684\u3002\u524d\u63d0\u662f\u670d\u52a1\u5668\u548c\u624b\u673a\u7684\u65f6\u95f4\u5fc5\u987b\u540c\u6b65\u3002\n<\/p>\n<p>\n\t\u63a5\u4e0b\u6765\uff0c\u5c31\u53ef\u4ee5\u7b97\u51fa\u54c8\u5e0c\u4e86\u3002<code> <\/code>\n<\/p>\n<p>\n\t<code>TOTP = HASH(SecretKey, TC)<\/code>\n<\/p>\n<p>\n\t\u4e0a\u9762\u4ee3\u7801\u4e2d\uff0c<code>HASH<\/code>\u5c31\u662f\u7ea6\u5b9a\u7684\u54c8\u5e0c\u51fd\u6570\uff0c\u9ed8\u8ba4\u662f SHA-1\u3002\n<\/p>\n<p>\n\tTOTP \u6709\u786c\u4ef6\u751f\u6210\u5668\u548c\u8f6f\u4ef6\u751f\u6210\u5668\u4e4b\u5206\uff0c\u90fd\u662f\u91c7\u7528\u4e0a\u9762\u7684\u7b97\u6cd5\u3002\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"\" src=\"http:\/\/www.ruanyifeng.com\/blogimg\/asset\/2017\/bg2017110109.jpg\" title=\"\" \/>\n<\/p>\n<p>\n\t\uff08\u8bf4\u660e\uff1aTOTP \u786c\u4ef6\u751f\u6210\u5668\uff09\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"\" src=\"http:\/\/www.ruanyifeng.com\/blogimg\/asset\/2017\/bg2017110109.png\" title=\"\" \/>\n<\/p>\n<p>\n\t\uff08\u8bf4\u660e\uff1aGoogle Authenticator \u662f\u4e00\u4e2a\u751f\u6210 TOTP \u7684\u624b\u673a App\uff09<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=2296\">\u53cc\u56e0\u7d20\u8ba4\u8bc1\uff082FA\uff09\u65b9\u6848TOTP \u7684\u7b97\u6cd5<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u57fa\u4e8e\u65f6\u95f4\u7684\u4e00\u6b21\u6027\u5bc6\u7801\u7b97\u6cd5\uff08TOTP\uff09\u662f\u4e00\u4e2a\u7b97\u6cd5\uff0c\u8ba1\u7b97\u51fa\u4e00\u4e2a\u4e00\u6b21\u6027\u5bc6\u7801\uff0c\u4ece\u4e00\u4e2a\u5171\u4eab\u5bc6\u94a5\u548c\u5f53\u524d\u65f6\u95f4\u3002\u5b83\u5df2\u88ab\u91c7\u7eb3\u4e3a\u56e0 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[1569,1568,75],"class_list":["post-2296","post","type-post","status-publish","format-standard","hentry","category-yyzt","tag-totp","tag-1568","tag-75"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2296","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2296"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2296\/revisions"}],"predecessor-version":[{"id":2297,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2296\/revisions\/2297"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2296"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2296"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2296"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}