def compute_sha256(filename):
try:<EOL><INDENT>h = sha256()<EOL>fd = open(filename, '<STR_LIT:rb>')<EOL>while True:<EOL><INDENT>buf = fd.read(<NUM_LIT>)<EOL>if buf in [None, "<STR_LIT>"]:<EOL><INDENT>break<EOL><DEDENT>h.update(buf.encode('<STR_LIT:utf-8>'))<EOL><DEDENT>fd.close()<EOL>return h.hexdigest()<EOL><DEDENT>except:<EOL><INDENT>output = run(["<STR_LIT>", "<STR_LIT>", filename])<EOL>return output.split("<STR_LIT:U+0020>")[<NUM_LIT:0>]<EOL><DEDENT>
Try the library. If it doesnt work, use the command line..