Ejemplo n.º 1
0
 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
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
 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
Ejemplo n.º 4
0
    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