{"id":352,"date":"2014-07-03T10:30:39","date_gmt":"2014-07-03T10:30:39","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=352"},"modified":"2014-07-03T10:30:39","modified_gmt":"2014-07-03T10:30:39","slug":"%e8%ae%a1%e7%ae%97%e6%96%87%e4%bb%b6md5%e5%80%bc%e7%9a%84%e5%b0%8f%e8%84%9a%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/352.html","title":{"rendered":"\u8ba1\u7b97\u6587\u4ef6MD5\u503c\u7684\u5c0f\u811a\u672c"},"content":{"rendered":"<p>\u6709\u65f6\u4e3a\u4e86\u65b9\u4fbf\u8ba1\u7b97\u6587\u4ef6\u7684MD5\u503c\uff0c\u9700\u8981\u4e00\u4e2a\u7531\u00a0<a href=\"http:\/\/keir.net\" target=\"_blank\">http:\/\/keir.net<\/a> \u5199\u7684\u5c0f\u5de5\u5177Hash.exe\uff0c\u4e0d\u8fc7\u6709\u4e9b\u65f6\u5019\u8fd8\u662f\u5e0c\u671b\u5199\u4e2a\u811a\u672c\u5b9e\u73b0\uff1a<\/p>\n<pre class=\"lang:python decode:true \">#!\/usr\/bin\/env python\n# -*- coding: utf8 -*-\nimport sys\nimport hashlib\n\ndef md5(fileName):\n    \"\"\"Compute md5 hash of the specified file\"\"\"\n    m = hashlib.md5()\n    try:\n        fd = open(fileName,\"rb\")\n    except IOError:\n        print \"Reading file has problem: \", filename\n        return\n    x = fd.read()\n    fd.close()\n    m.update(x)\n    return m.hexdigest()\n\nif __name__ == \"__main__\":\n    for eachFile in sys.argv[1:]:\n        print \"%s %s\" % (md5(eachFile), eachFile)<\/pre>\n<p>\u5c06\u811a\u672c\u4fdd\u5b58\u4e3acalcMD5.py\uff0c\u7136\u540e\u518d\u7ec8\u7aef\u4e0b\u8fd0\u884c\uff1a<\/p>\n<p><span style=\"color: rgb(0, 0, 255);\">D:&gt; python calcMD5.py file1 [file2]&#8230;<\/span><\/p>\n<p>\u5373\u53ef\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u65f6\u4e3a\u4e86\u65b9\u4fbf\u8ba1\u7b97\u6587\u4ef6\u7684MD5\u503c\uff0c\u9700\u8981\u4e00\u4e2a\u7531\u00a0http:\/\/keir.net \u5199\u7684\u5c0f\u5de5\u5177Hash.exe\uff0c\u4e0d\u8fc7\u6709 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,12],"tags":[172,8],"class_list":["post-352","post","type-post","status-publish","format-standard","hentry","category-programing","category-tools","tag-hashlib-md5","tag-python"],"views":4358,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/352","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=352"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/352\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=352"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=352"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=352"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}