def test_get_hashes(): # Download flag text file to current directory. url = 'http://textfiles.com/art/flag' file_name = 'flag.txt' flag = urlopen(url) output = open(file_name,'wb') output.write(flag.read()) output.close() # Now get all hashes of all files in current directory. file_hashes = get_all_hashes.get_all_hashes('.') # The text file should be in the dictionary of hashes, with the # correct hash. assert(file_hashes['./flag.txt'] == 'a0cd62d98374cb5dfbd1c53a220e12fa') # Delete the file. os.remove('flag.txt')
def test_get_hashes(): # Download flag text file to current directory. url = 'http://textfiles.com/art/flag' file_name = 'flag.txt' flag = urlopen(url) output = open(file_name, 'wb') output.write(flag.read()) output.close() # Now get all hashes of all files in current directory. file_hashes = get_all_hashes.get_all_hashes('.') # The text file should be in the dictionary of hashes, with the # correct hash. assert (file_hashes['./flag.txt'] == 'a0cd62d98374cb5dfbd1c53a220e12fa') # Delete the file. os.remove('flag.txt')
import json from get_all_hashes import get_all_hashes # Get hashes for all files in all subdirectories of the # decompressed ds009 directory. if __name__ == "__main__": file_hashes = get_all_hashes('ds009') with open('ds009_hashes2.json', 'w') as out: json.dump(file_hashes, out)
import json from get_all_hashes import get_all_hashes # Get hashes for all files in all subdirectories of the # decompressed ds009 directory. if __name__ == "__main__": file_hashes = get_all_hashes('ds009') with open('ds009_hashes.json', 'w') as out: json.dump(file_hashes, out)