mirror of
https://github.com/autistic-symposium/sec-pentesting-toolkit.git
synced 2025-04-29 12:06:07 -04:00
checksum
This commit is contained in:
parent
b58e55f415
commit
f211c1cbab
@ -1,3 +1,8 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
__author__ = "bt3"
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
EXAMPLE FROM ASIS 2013, WITH THE CONCATENATED HASH:
|
EXAMPLE FROM ASIS 2013, WITH THE CONCATENATED HASH:
|
||||||
|
|
||||||
|
21
Cryptography/MD5/checksum_file.py
Normal file
21
Cryptography/MD5/checksum_file.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
__author__ = "bt3"
|
||||||
|
|
||||||
|
'''
|
||||||
|
Calculate the MD5 checksum of a file.
|
||||||
|
We work on chunks to avoid using too much memory when the file is large.
|
||||||
|
'''
|
||||||
|
|
||||||
|
import os
|
||||||
|
from Crypto.Hash import MD5
|
||||||
|
def get_file_checksum(filename):
|
||||||
|
h = MD5.new()
|
||||||
|
chunk_size = 8192
|
||||||
|
with open(filename, 'rb') as f:
|
||||||
|
while True:
|
||||||
|
chunk = f.read(chunk_size)
|
||||||
|
if len(chunk) == 0:
|
||||||
|
break
|
||||||
|
h.update(chunk)
|
||||||
|
return h.hexdigest()
|
@ -1,4 +1,4 @@
|
|||||||
sisu#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
__author__ = "bt3"
|
__author__ = "bt3"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user