Python

#!/usr/bin/python# usando a biblioteca hashlib para checar o md5sum # ou seja a integridade de arquivosimportos,sysimporthashlibdefmd5(fileName,excludeLine="",includeLine=""):"""Compute md5 hash of the specified file"""m=hashlib.md5()try:fd=open(fileName,"rb")exceptIOError:print"Unable to open the file in readmode:",fileNamereturncontent=fd.readlines()fd.close()foreachLineincontent:ifexcludeLineandeachLine.startswith(excludeLine):continuem.update(eachLine)m.update(includeLine)returnm.hexdigest()if__name__=="__main__":foreachFileinsys.argv[1:]:print"%s%s"%(md5(eachFile),eachFile)