#!/usr/bin/python # Repeatedly run a sha256 on random data. Keeps a rolling buffer of the last # hashes and re-checks them. Prints an error ONLY if a mismatch is # found. If a mismatch is found, you have a hardware problem. from hashlib import sha256 from collections import deque import random buflen = 100000 hashbuf = deque(maxlen=buflen) for i in range(buflen): hashbuf.append([str(i), sha256(str(i)).hexdigest()]) while True: k, khash = hashbuf.popleft() pophash = sha256(k).hexdigest() if pophash != khash: print "ERROR: sha256(%s) = %s does not match:"%(k, khash) print " sha256(%s) = %s"%(k, pophash) k = str(random.getrandbits(1000)) khash = sha256(k).hexdigest() hashbuf.append([k, khash])