Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # this is from The Python
- # Standard Library by example
- # ISBN13: 9780321767349
- import hashlib
- from hashlib_data import lorem
- h = hashlib.md5()
- h.update(lorem)
- all_at_once = h.hexdigest()
- def chunkize(size, text):
- "Return parts of the text in size-based increments."
- start = 0
- while start < len(text):
- chunk = text[start:start + size]
- yield chunk
- start += size
- return
- h = hashlib.md5()
- for chunk in chunkize(64, lorem):
- h.update(chunk)
- line_by_line = h.hexdigest()
- print 'All at once :', all_at_once
- print 'Line by line :', line_by_line
- print 'Same :', (all_at_once == line_by_line)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement