def isValidPuzzle(self,puzzle): puzzle = "%s" %puzzle crc1 = sofi_crypt.crc16(puzzle[0:18]) crc2, = struct.unpack('>H',puzzle[18:20]) if(crc1 == crc2): return True else: return False
def isValidPuzzle(self, puzzle): puzzle = "%s" % puzzle crc1 = sofi_crypt.crc16(puzzle[0:18]) crc2, = struct.unpack('>H', puzzle[18:20]) if (crc1 == crc2): return True else: return False
def createPuzzle(self,preimageSize=4): self.count=0 if(preimageSize>20): return None try: randgen = random.SystemRandom() except: randgen = random b = bytearray() for _i in xrange(preimageSize): b.append(randgen.randint(0,255)) s = hashlib.sha1("%s" %b).digest() z = bytearray(struct.pack('>18sH',s[0:18],sofi_crypt.crc16(s[0:18]))) return z
def createPuzzle(self, preimageSize=4): self.count = 0 if (preimageSize > 20): return None try: randgen = random.SystemRandom() except: randgen = random b = bytearray() for _i in xrange(preimageSize): b.append(randgen.randint(0, 255)) s = hashlib.sha1("%s" % b).digest() z = bytearray(struct.pack('>18sH', s[0:18], sofi_crypt.crc16(s[0:18]))) return z