{"id":222546,"date":"2021-07-24T10:05:18","date_gmt":"2021-07-24T02:05:18","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=222546"},"modified":"2021-07-15T09:06:45","modified_gmt":"2021-07-15T01:06:45","slug":"python-model-getpass","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/python-model-getpass.html","title":{"rendered":"\u5982\u4f55\u8ba9Python\u4e0d\u56de\u663e\u83b7\u53d6\u5bc6\u7801\u8f93\u5165"},"content":{"rendered":"
\u5bfc\u8bfb<\/td>\n | \u5bc6\u7801\u5bf9\u7a0b\u5e8f\u5458\u6765\u8bf4\u5c24\u5176\u91cd\u8981\u3002\u4f60\u4e0d\u5e94\u8be5\u5728\u4e0d\u52a0\u5bc6\u7684\u60c5\u51b5\u4e0b\u5b58\u50a8\u5b83\u4eec\uff0c\u800c\u4e14\u4f60\u4e5f\u4e0d\u5e94\u8be5\u5728\u7528\u6237\u8f93\u5165\u5bc6\u7801\u7684\u65f6\u5019\u663e\u793a\u51fa\u8f93\u5165\u7684\u5185\u5bb9\u3002\u5f53\u6211\u51b3\u5b9a\u8981\u63d0\u9ad8\u6211\u7684\u7b14\u8bb0\u672c\u7535\u8111\u7684\u5b89\u5168\u6027\u65f6\uff0c\u8fd9\u5bf9\u6211\u6765\u8bf4\u53d8\u5f97\u7279\u522b\u91cd\u8981\u3002\u6211\u5bf9\u6211\u7684\u5bb6\u76ee\u5f55\u8fdb\u884c\u4e86\u52a0\u5bc6\uff0c\u4f46\u5f53\u6211\u767b\u5f55\u540e\uff0c\u4efb\u4f55\u4ee5\u7eaf\u6587\u672c\u5f62\u5f0f\u5b58\u50a8\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u5bc6\u7801\u90fd\u6709\u53ef\u80fd\u66b4\u9732\u5728\u5077\u7aa5\u8005\u9762\u524d\u3002 \n<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n \u7528 GPG \u548c Python \u7684 getpass \u6a21\u5757\u7ed9\u4f60\u7684\u5bc6\u7801\u591a\u4e00\u5c42\u5b89\u5168\u4fdd\u969c\u3002<\/p>\n <\/p>\n \u5177\u4f53\u6765\u8bf4\uff0c\u6211\u4f7f\u7528\u4e00\u4e2a\u540d\u4e3a Mutt \u7684\u5e94\u7528\u4f5c\u4e3a\u6211\u7684\u7535\u5b50\u90ae\u4ef6\u5ba2\u6237\u7aef\u3002\u5b83\u53ef\u4ee5\u8ba9\u6211\u5728\u6211\u7684 Linux \u7ec8\u7aef\u4e2d\u9605\u8bfb\u548c\u64b0\u5199\u7535\u5b50\u90ae\u4ef6\uff0c\u4f46\u901a\u5e38\u5b83\u5e0c\u671b\u5728\u5176\u914d\u7f6e\u6587\u4ef6\u4e2d\u6709\u4e00\u4e2a\u5bc6\u7801\u3002\u6211\u9650\u5236\u4e86\u6211\u7684 Mutt \u914d\u7f6e\u6587\u4ef6\u7684\u6743\u9650\uff0c\u4ee5\u4fbf\u53ea\u6709\u6211\u53ef\u4ee5\u770b\u5230\u5b83\uff0c\u6211\u662f\u6211\u7684\u7b14\u8bb0\u672c\u7535\u8111\u7684\u552f\u4e00\u7528\u6237\uff0c\u6240\u4ee5\u6211\u5e76\u4e0d\u771f\u7684\u62c5\u5fc3\u7ecf\u8fc7\u8ba4\u8bc1\u7684\u7528\u6237\u4f1a\u65e0\u610f\u4e2d\u770b\u5230\u6211\u7684\u914d\u7f6e\u6587\u4ef6\u3002\u76f8\u53cd\uff0c\u6211\u60f3\u4fdd\u62a4\u81ea\u5df1\uff0c\u65e0\u8bba\u662f\u4e3a\u4e86\u5439\u5618\u8fd8\u662f\u4e3a\u4e86\u7248\u672c\u63a7\u5236\uff0c\u4e0d\u81f3\u4e8e\u5fc3\u4e0d\u5728\u7109\u5730\u628a\u6211\u7684\u914d\u7f6e\u53d1\u5e03\u5230\u7f51\u4e0a\uff0c\u628a\u6211\u7684\u5bc6\u7801\u66b4\u9732\u4e86\u3002\u6b64\u5916\uff0c\u867d\u7136\u6211\u4e0d\u5e0c\u671b\u6211\u7684\u7cfb\u7edf\u4e0a\u6709\u4e0d\u53d7\u6b22\u8fce\u7684\u5ba2\u4eba\uff0c\u4f46\u6211\u786e\u5b9e\u60f3\u786e\u4fdd\u5165\u4fb5\u8005\u4e0d\u80fd\u901a\u8fc7\u5bf9\u6211\u7684\u914d\u7f6e\u4e0a\u8fd0\u884c cat \u5c31\u83b7\u5f97\u6211\u7684\u5bc6\u7801\u3002<\/p>\n Python GnuPG<\/strong><\/div>\n Python \u6a21\u5757 python-gnupg \u662f gpg \u5e94\u7528\u7684\u4e00\u4e2a Python \u5c01\u88c5\u3002\u8be5\u6a21\u5757\u7684\u540d\u5b57\u662f python-gnupg\uff0c\u4f60\u4e0d\u8981\u628a\u5b83\u548c\u4e00\u4e2a\u53eb\u505a gnupg \u7684\u6a21\u5757\u6df7\u6dc6\u3002<\/p>\n GnuPG(GPG) \u662f Linux \u7684\u9ed8\u8ba4\u52a0\u5bc6\u7cfb\u7edf\uff0c\u6211\u4ece 2009 \u5e74\u5de6\u53f3\u5f00\u59cb\u4f7f\u7528\u5b83\u3002\u6211\u5bf9\u5b83\u5f88\u719f\u6089\uff0c\u5bf9\u5b83\u7684\u5b89\u5168\u6027\u6709\u5f88\u9ad8\u7684\u4fe1\u4efb\u3002<\/p>\n \u6211\u51b3\u5b9a\u5c06\u6211\u7684\u5bc6\u7801\u8f93\u5165 Mutt \u7684\u6700\u597d\u65b9\u6cd5\u662f\u5c06\u6211\u7684\u5bc6\u7801\u5b58\u50a8\u5728\u4e00\u4e2a\u52a0\u5bc6\u7684 GPG \u6587\u4ef6\u4e2d\uff0c\u521b\u5efa\u4e00\u4e2a\u63d0\u793a\u6211\u7684 GPG \u5bc6\u7801\u6765\u89e3\u9501\u8fd9\u4e2a\u52a0\u5bc6\u6587\u4ef6\uff0c\u7136\u540e\u5c06\u5bc6\u7801\u4ea4\u7ed9 Mutt(\u5b9e\u9645\u4e0a\u662f\u4ea4\u7ed9 offlineimap \u547d\u4ee4\uff0c\u6211\u7528\u5b83\u6765\u540c\u6b65\u6211\u7684\u7b14\u8bb0\u672c\u548c\u7535\u5b50\u90ae\u4ef6\u670d\u52a1\u5668)\u3002<\/p>\n \u7528 Python \u83b7\u53d6\u7528\u6237\u8f93\u5165 \u662f\u975e\u5e38\u5bb9\u6613\u7684\u3002\u5bf9 input \u8fdb\u884c\u8c03\u7528\uff0c\u65e0\u8bba\u7528\u6237\u8f93\u5165\u4ec0\u4e48\uff0c\u90fd\u4f1a\u88ab\u5b58\u50a8\u4e3a\u4e00\u4e2a\u53d8\u91cf\uff1a<\/p>\n print(\"Enter password: \") \r\nmyinput = input() \r\nprint(\"You entered: \", myinput)<\/pre>\n |