2007年03月19日 星期一 23:48
用python的md5获得散列数值,每个文件的数值都是不一样的. 但是我对从数码相机取下来的照片取散列值,却发现一批照片的散列值都是一样的,但是照片的内容是不一样的,有人碰过这样的问题吗?
2007年03月20日 星期二 08:45
那几乎是不可能的, 如果你确定,向山东大学再提交一次吧。 On 3/19/07, OnMyWay <onmyway.q在gmail.com> wrote: > 用python的md5获得散列数值,每个文件的数值都是不一样的. > > 但是我对从数码相机取下来的照片取散列值,却发现一批照片的散列值都是一样的,但是照片的内容是不一样的,有人碰过这样的问题吗? > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese -- LinuX Power
2007年03月20日 星期二 09:08
你方法有问题吧~
2007年03月20日 星期二 09:59
以下是原码:用SHA取散列值也是一样的。或者python算法有问题? def fuFileList(sPath): liFileId = [] full_size = 0 for dir,opt,filename in os.walk(sPath): for fn in filename: fn_path = os.path.join(dir,fn) file_size = os.path.getsize(fn_path) full_size = full_size + file_size f = open(fn_path,'r') m = md5.new() m.update(f.read()) liFileId.append((fn,str(os.path.getsize(fn_path)),m.hexdigest())) f.close print full_size return liFileId 2007/3/20, zhang peng <finalmdj在gmail.com>: > 你方法有问题吧~ > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese
2007年03月20日 星期二 10:12
运行结果: 文件名|大小(byte)|md5 DSCN0813.JPG|1565067|1d258715347c0a91f7b9cfa6c33c9463 DSCN0814.JPG|1674418|1d258715347c0a91f7b9cfa6c33c9463 DSCN0815.JPG|1670100|1d258715347c0a91f7b9cfa6c33c9463 DSCN0816.JPG|1603238|1d258715347c0a91f7b9cfa6c33c9463 DSCN0817.JPG|1658450|1d258715347c0a91f7b9cfa6c33c9463 DSCN0818.JPG|1720378|1d258715347c0a91f7b9cfa6c33c9463 DSCN0819.JPG|1676417|1d258715347c0a91f7b9cfa6c33c9463 DSCN0820.JPG|1779464|1d258715347c0a91f7b9cfa6c33c9463 DSCN0821.JPG|1708769|1d258715347c0a91f7b9cfa6c33c9463 DSCN0822.JPG|1783756|1d258715347c0a91f7b9cfa6c33c9463 DSCN0823.JPG|1814235|1d258715347c0a91f7b9cfa6c33c9463 DSCN0824.JPG|1735070|1d258715347c0a91f7b9cfa6c33c9463 DSCN0824small.JPG|173850|07c80374a99360ebd2d2a3436d59f913 DSCN0825.JPG|1706571|1d258715347c0a91f7b9cfa6c33c9463 DSCN0826.JPG|1749689|1d258715347c0a91f7b9cfa6c33c9463 DSCN0827.JPG|1676857|1d258715347c0a91f7b9cfa6c33c9463 DSCN0828.JPG|1665509|1d258715347c0a91f7b9cfa6c33c9463 DSCN0829.JPG|1719222|1d258715347c0a91f7b9cfa6c33c9463 DSCN0830.JPG|1529316|18b769d286b1430e0a261c595084efaa DSCN0831.JPG|1647300|1d258715347c0a91f7b9cfa6c33c9463 DSCN0832.JPG|1382571|1d258715347c0a91f7b9cfa6c33c9463 DSCN0833.JPG|1638702|1d258715347c0a91f7b9cfa6c33c9463 DSCN0834.JPG|1561789|1d258715347c0a91f7b9cfa6c33c9463 DSCN0835.JPG|1561341|1d258715347c0a91f7b9cfa6c33c9463 DSCN0836.JPG|1612781|1d258715347c0a91f7b9cfa6c33c9463 DSCN0837.JPG|1787172|1d258715347c0a91f7b9cfa6c33c9463 DSCN0838.JPG|1713523|1d258715347c0a91f7b9cfa6c33c9463 DSCN0839.JPG|1006780|1d258715347c0a91f7b9cfa6c33c9463 在 07-3-20,OnMyWay<onmyway.q在gmail.com> 写道: > 以下是原码:用SHA取散列值也是一样的。或者python算法有问题? > def fuFileList(sPath): > liFileId = [] > full_size = 0 > for dir,opt,filename in os.walk(sPath): > for fn in filename: > fn_path = os.path.join(dir,fn) > file_size = os.path.getsize(fn_path) > full_size = full_size + file_size > f = open(fn_path,'r') > m = md5.new() > m.update(f.read()) > liFileId.append((fn,str(os.path.getsize(fn_path)),m.hexdigest())) > f.close > print full_size > return liFileId > > 2007/3/20, zhang peng <finalmdj在gmail.com>: > > 你方法有问题吧~ > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > > Detail Info: http://python.cn/mailman/listinfo/python-chinese >
2007年03月20日 星期二 10:17
On 3/20/07, OnMyWay <onmyway.q在gmail.com> wrote: > 以下是原码:用SHA取散列值也是一样的。或者python算法有问题? > def fuFileList(sPath): > liFileId = [] > full_size = 0 > for dir,opt,filename in os.walk(sPath): > for fn in filename: > fn_path = os.path.join(dir,fn) > file_size = os.path.getsize(fn_path) > full_size = full_size + file_size > f = open(fn_path,'r') > m = md5.new() > m.update(f.read()) > liFileId.append((fn,str(os.path.getsize(fn_path)),m.hexdigest())) > f.close > print full_size > return liFileId > 你的程序错在open的第二个参数。应该是'rb',不是'r' -- Best Regards, Leo Jay
2007年03月20日 星期二 10:34
高手指点一下,问题立马解决了。谢谢!:) 在 07-3-20,Leo Jay<python.leojay在gmail.com> 写道: > On 3/20/07, OnMyWay <onmyway.q在gmail.com> wrote: > > 以下是原码:用SHA取散列值也是一样的。或者python算法有问题? > > def fuFileList(sPath): > > liFileId = [] > > full_size = 0 > > for dir,opt,filename in os.walk(sPath): > > for fn in filename: > > fn_path = os.path.join(dir,fn) > > file_size = os.path.getsize(fn_path) > > full_size = full_size + file_size > > f = open(fn_path,'r') > > m = md5.new() > > m.update(f.read()) > > liFileId.append((fn,str(os.path.getsize(fn_path)),m.hexdigest())) > > f.close > > print full_size > > return liFileId > > > > 你的程序错在open的第二个参数。应该是'rb',不是'r' > > -- > Best Regards, > Leo Jay > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese
Zeuux © 2025
京ICP备05028076号