Author: poeml Date: Tue Aug 31 23:08:48 2010 New Revision: 8079 URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain?rev=8079&view=rev Log: mb makehashes: - in addition to the sha1 hash, include md5 and sha256 in the bt info hash calculation (which mod_mirrorbrain is going to include in the info dict, as well) Modified: trunk/mb/mb/hashes.py Modified: trunk/mb/mb/hashes.py URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain/trunk/mb/mb/hashes.py?rev=8079&r1=8078&r2=8079&view=diff ============================================================================== --- trunk/mb/mb/hashes.py (original) +++ trunk/mb/mb/hashes.py Tue Aug 31 23:08:48 2010 _at_@ -21,15 +21,18 @@ # I think Python 2.4 didn't have a sha256 counterpart sha256 = None -PIECESIZE = 262144 -SHA1_DIGESTSIZE = 20 +DEFAULT_PIECESIZE = 262144 +MD5_DIGESTSIZE = 16 +SHA1_DIGESTSIZE = 20 +SHA256_DIGESTSIZE = 32 + class Hasheable: """represent a file and its metadata""" def __init__(self, basename, src_dir=None, dst_dir=None, base_dir=None, do_zsync_hashes=False, - do_chunked_hashes=True, chunk_size=PIECESIZE): + do_chunked_hashes=True, chunk_size=DEFAULT_PIECESIZE): self.basename = basename if src_dir: self.src_dir = src_dir _at_@ -450,6 +453,9 @@ '4:name', str(len(self.basename)), ':', self.basename, '12:piece length', 'i', str(self.chunk_size), 'e', '6:pieces', str(len(self.pieces) * SHA1_DIGESTSIZE), ':', ''.join(self.pieces), + '3:md5', str(MD5_DIGESTSIZE), ':', self.md5, + '4:sha1', str(SHA1_DIGESTSIZE), ':', self.sha1, + '6:sha256', str(SHA256_DIGESTSIZE), ':', self.sha256, 'e'] h = sha1.sha1() _______________________________________________ mirrorbrain-commits mailing list Archive: http://mirrorbrain.org/archive/mirrorbrain-commits/ Note: To remove yourself from this list, send a mail with the content unsubscribe to the address mirrorbrain-commits-request_at_mirrorbrain.orgReceived on Tue Aug 31 2010 - 21:08:54 GMT
This archive was generated by hypermail 2.3.0 : Mon Feb 20 2012 - 23:47:04 GMT