Readme typo fix, sha512 benchmark, comment fix, better random for ECC
This commit is contained in:
parent
4b02417b61
commit
6424c82887
4 changed files with 24 additions and 5 deletions
|
@ -9,10 +9,28 @@ def sha1sum(file, blocksize=65536):
|
|||
return hash.hexdigest()
|
||||
|
||||
|
||||
def sha512sum(file, blocksize=65536):
|
||||
if hasattr(file, "endswith"): # Its a string open it
|
||||
file = open(file, "rb")
|
||||
hash = hashlib.sha512()
|
||||
for block in iter(lambda: file.read(blocksize), ""):
|
||||
hash.update(block)
|
||||
return hash.hexdigest()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import cStringIO as StringIO
|
||||
a = StringIO.StringIO()
|
||||
a.write("hello!")
|
||||
a.seek(0)
|
||||
print hashlib.sha1("hello!").hexdigest()
|
||||
print sha1sum(a)
|
||||
print sha1sum(a)
|
||||
|
||||
import time
|
||||
s = time.time()
|
||||
print sha1sum(open("F:\\Temp\\bigfile")),
|
||||
print time.time()-s
|
||||
|
||||
s = time.time()
|
||||
print sha512sum(open("F:\\Temp\\bigfile")),
|
||||
print time.time()-s
|
Loading…
Add table
Add a link
Reference in a new issue