How to calculate MD5 check sum in Python
来源:互联网 发布:sql server 2014版本 编辑:程序博客网 时间:2024/05/06 10:50
import sysimport hashlibimport md5def getMd5(filePath): f = open(filePath, "rb") m = hashlib.md5() while True: data = f.read(8192) if not data: break m.update(data) f.close() return m.hexdigest()if __name__ == "__main__": if len(sys.argv)<=1 or sys.argv[1] == "-h" or sys.argv[1] == "--help": print("using md5.py <filepath>\n") print("using md5.py [-h|--help] to display help info\n") sys.exit() try: filePath = sys.argv[1] print("md5 check sum:" + str(getMd5(filePath))) except Exception(e): print(e)
Save the code into a python file.
To use this python file, just execute the command below in cmd or other shells, md5.py is the file name of the py file you save, /home/test/example.dat is the file whose md5 will be calculated :
python md5.py /home/test/example.dat
0 0
- How to calculate MD5 check sum in Python
- How to calculate the MD5 hash of a large file in C?
- How to calculate CRC in C#?
- How to check ip address in linux
- how to calculate ANOVA
- How to calculate the tier prices in Magento
- how to calculate the textsize of TLatex in CernRoot
- How to check in your files in ADE
- how to check in code to ooo-build
- How to use NQ logs to check data in DB
- How to calculate t distributions
- How to check the MSOLAP Provider used in connection string
- How to check the external public IP in linux
- How to check for NAN / INF / IND in C++
- How to check the Gateway address in Windows
- How to check environment variable in robot framework?
- Android How to Check if the App is in Background
- To check how many messages are in a MSMQ Queue
- storm消息确认机制<转>
- 《炉石传说》架构设计赏析(5):卡牌&技能的静态数据组织
- Jetty的SelectChannelConnector分析
- 判断同一个单词是否连续出现了两次
- 东软学习,hibernate初级学习的部分截图和笔记(一)-入门以及XMl基础配置
- How to calculate MD5 check sum in Python
- Makefile学习(二)[第二版]
- oracle rac下调节redo log file 文件大小
- 【学习】对产品经理的认知
- 解决“在eclipse中配置Tomcat时,出现Cannot create a server using the selected type的错误”的问题
- iOS App瘦身注意armv7 armv7s arm64 [转]
- 关于软件授权及自由软件
- Android 开发简介
- 排序算法——插入排序