Last active
April 25, 2017 21:43
-
-
Save Mohitsharma44/97080c4e3c1a8512e21786f8e2b2a977 to your computer and use it in GitHub Desktop.
sha256 for a file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib | |
import sys | |
import urllib2 | |
import optparse | |
def sha256_checksum(url, block_size=65536): | |
filename = urllib2.urlopen(url) | |
sha256 = hashlib.sha256() | |
for block in iter(lambda: filename.read(block_size), b''): | |
sha256.update(block) | |
return sha256.hexdigest() | |
if __name__ == '__main__': | |
opt = optparse.OptionParser() | |
opt.add_option('--url', '-u', default='https://raw.githubusercontent.com/hk1953/ucsl-image/master/image/jupyter_config.py') | |
options, args = opt.parse_args() | |
print sha256_checksum(options.url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment