def audit(self, seed, store_path, height): """Do an audit over the data.""" audit_results = [] for i in range(height): seed_hash = self.build_seed(i) seed_path = os.path.join(store_path, seed_hash) digest = partialhash.sample(seed_path, 1024, sample_count=3, seed=seed) audit_results.append(binascii.hexlify(digest)) return audit_results
def audit(self, seed, store_path, height): """Do an audit over the data.""" audit_results = [] seeds = self.build_seeds(height) for shard_num, seed_hash in enumerate(seeds): seed_path = os.path.join(store_path, seed_hash) digest = partialhash.sample(seed_path, 1024, sample_count=3, seed=seed) audit_results.append(binascii.hexlify(digest)) return audit_results
def audit(self, seed, store_path, height): """Do an audit over the data.""" audit_results = [] seeds = self.build_seeds(height) for shard_num, seed_hash in enumerate(seeds): seed_path = self._get_shard_path(store_path, seed_hash) digest = partialhash.sample(seed_path, 1024, sample_count=3, seed=seed) audit_results.append(binascii.hexlify(digest)) return audit_results
from __future__ import unicode_literals import binascii import partialhash path = "examples/random.data" # sha256 hash of full file digest = partialhash.compute(path) # file path or file like object print(binascii.hexlify(digest)) # sha256 hash of first 1024 bytes digest = partialhash.compute(path, length=1024) print(binascii.hexlify(digest)) # sha256 hash, skipping the first 512 bytes digest = partialhash.compute(path, offset=512) print(binascii.hexlify(digest)) # sha256 hash of seed + file data digest = partialhash.compute(path, seed=b'seeddata') print(binascii.hexlify(digest)) # sha256 hash of 256 byte sample with given seed digest = partialhash.sample(path, 256, seed=b'seeddata') print(binascii.hexlify(digest)) # sha256 hash of three 256 byte samples with given seed # sample data will not overlap until sample size exceeds file size digest = partialhash.sample(path, 256, sample_count=3, seed=b'seeddata') print(binascii.hexlify(digest))