Advertisement
rfmonk

hashlib_new.py

Jan 30th, 2014
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. # this is from The Python
  4. # Standard Library by example
  5. # ISBN13: 9780321767349
  6.  
  7. import hashlib
  8. import sys
  9.  
  10. try:
  11.     hash_name = sys.argv[1]
  12. except IndexError:
  13.     print 'Specify the hash name as the first argument.'
  14. else:
  15.     try:
  16.         data = sys.argv[2]
  17.     except IndexError:
  18.         from hashlib_data import lorem as data
  19.  
  20.     h = hashlib.new(hash_name)
  21.     h.update(data)
  22.     print h.hexdigest()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement