thirdparty/blake/blake.py
def final(self, data=''):
        """ finalize the hash -- pad and hash remaining data
            returns hashval, the digest
        """
        if self.state == 3:
            # we have already finalized so simply return the
            # previously calculated/stored hash value
            return self.hash

        if data:
            self.update(data)

        ZZ = b'\x00'
        ZO = b'\x01'
        OZ = b'\x80'
        OO = b'\x81'
        PADDING = OZ + ZZ * 128  # pre-formatted padding data

        # copy nb. bits hash in total as a 64-bit BE word
        # copy nb. bits hash in total as a 128-bit BE word
        tt = self.t + (len(self.cache) << 3)
        if self.BLKBYTES == 64:
            msglen = self._int2eightByte(tt)
        else:
            low = tt & self.MASK
            high = tt >> self.WORDBITS
            msglen = self._int2eightByte(high) + self._int2eightByte(low)

        # size of block without the words at the end that count
        # the number of bits, 55 or 111.
        # Note: (((self.WORDBITS/8)*2)+1) equals ((self.WORDBITS>>2)+1)
        sizewithout = self.BLKBYTES - ((self.WORDBITS >> 2) + 1)

        if len(self.cache) == sizewithout:
            # special case of one padding byte
            self.t -= 8
            if self.hashbitlen in [224, 384]:
                self.update(OZ)
            else:
                self.update(OO)
        else:
            if len(self.cache) < sizewithout:
                # enough space to fill the block
                # use t=0 if no remaining data
                if len(self.cache) == 0:
                    self.nullt = 1
                self.t -= (sizewithout - len(self.cache)) << 3
                self.update(PADDING[:sizewithout - len(self.cache)])
            else:
                # NOT enough space, need 2 compressions
                #   ...add marker, pad with nulls and compress
                self.t -= (self.BLKBYTES - len(self.cache)) << 3
                self.update(PADDING[:self.BLKBYTES - len(self.cache)])
                #   ...now pad w/nulls leaving space for marker & bit count
                self.t -= (sizewithout + 1) << 3
                self.update(PADDING[1:sizewithout + 1])  # pad with zeroes

                self.nullt = 1  # raise flag to set t=0 at the next _compress

            # append a marker byte
            if self.hashbitlen in [224, 384]:
                self.update(ZZ)
            else:
                self.update(ZO)
            self.t -= 8

        # append the number of bits (long long)
        self.t -= self.BLKBYTES
        self.update(msglen)

        hashval = []
        if self.BLKBYTES == 64:
            for h in self.h:
                hashval.append(self._int2fourByte(h))
        else:
            for h in self.h:
                hashval.append(self._int2eightByte(h))

        self.hash = b''.join(hashval)[:self.hashbitlen >> 3]
        self.state = 3

        return self.hash
 finalize the hash -- pad and hash remaining data
            returns hashval, the digest
        
finalize the hash -- pad and hash remaining data
returns hashval, the digest
finalize the hash -- pad and hash remaining data returns hashval the digest
def final(self, data=''):
        if self.state == 3:
            return self.hash
        if data:
            self.update(data)
        ZZ = b'\x00'
        ZO = b'\x01'
        OZ = b'\x80'
        OO = b'\x81'
        PADDING = OZ + ZZ * 128  
        tt = self.t + (len(self.cache) << 3)
        if self.BLKBYTES == 64:
            msglen = self._int2eightByte(tt)
        else:
            low = tt & self.MASK
            high = tt >> self.WORDBITS
            msglen = self._int2eightByte(high) + self._int2eightByte(low)
        sizewithout = self.BLKBYTES - ((self.WORDBITS >> 2) + 1)
        if len(self.cache) == sizewithout:
            self.t -= 8
            if self.hashbitlen in [224, 384]:
                self.update(OZ)
            else:
                self.update(OO)
        else:
            if len(self.cache) < sizewithout:
                if len(self.cache) == 0:
                    self.nullt = 1
                self.t -= (sizewithout - len(self.cache)) << 3
                self.update(PADDING[:sizewithout - len(self.cache)])
            else:
                self.t -= (self.BLKBYTES - len(self.cache)) << 3
                self.update(PADDING[:self.BLKBYTES - len(self.cache)])
                self.t -= (sizewithout + 1) << 3
                self.update(PADDING[1:sizewithout + 1])  
                self.nullt = 1  
            if self.hashbitlen in [224, 384]:
                self.update(ZZ)
            else:
                self.update(ZO)
            self.t -= 8
        self.t -= self.BLKBYTES
        self.update(msglen)
        hashval = []
        if self.BLKBYTES == 64:
            for h in self.h:
                hashval.append(self._int2fourByte(h))
        else:
            for h in self.h:
                hashval.append(self._int2eightByte(h))
        self.hash = b''.join(hashval)[:self.hashbitlen >> 3]
        self.state = 3
        return self.hash
def final ( self , data = '' ) : if self . state == 3 : return self . hash if data : self . update ( data ) ZZ = b'\x00' ZO = b'\x01' OZ = b'\x80' OO = b'\x81' PADDING = OZ + ZZ * 128 tt = self . t + ( len ( self . cache ) << 3 ) if self . BLKBYTES == 64 : msglen = self . _int2eightByte ( tt ) else : low = tt & self . MASK high = tt >> self . WORDBITS msglen = self . _int2eightByte ( high ) + self . _int2eightByte ( low ) sizewithout = self . BLKBYTES - ( ( self . WORDBITS >> 2 ) + 1 ) if len ( self . cache ) == sizewithout : self . t -= 8 if self . hashbitlen in [ 224 , 384 ] : self . update ( OZ ) else : self . update ( OO ) else : if len ( self . cache ) < sizewithout : if len ( self . cache ) == 0 : self . nullt = 1 self . t -= ( sizewithout - len ( self . cache ) ) << 3 self . update ( PADDING [ : sizewithout - len ( self . cache ) ] ) else : self . t -= ( self . BLKBYTES - len ( self . cache ) ) << 3 self . update ( PADDING [ : self . BLKBYTES - len ( self . cache ) ] ) self . t -= ( sizewithout + 1 ) << 3 self . update ( PADDING [ 1 : sizewithout + 1 ] ) self . nullt = 1 if self . hashbitlen in [ 224 , 384 ] : self . update ( ZZ ) else : self . update ( ZO ) self . t -= 8 self . t -= self . BLKBYTES self . update ( msglen ) hashval = [ ] if self . BLKBYTES == 64 : for h in self . h : hashval . append ( self . _int2fourByte ( h ) ) else : for h in self . h : hashval . append ( self . _int2eightByte ( h ) ) self . hash = b'' . join ( hashval ) [ : self . hashbitlen >> 3 ] self . state = 3 return self . hash
finalize the hash -- pad and hash remaining data
returns hashval, the digest
finalize the hash -- pad and hash remaining data returns hashval the digest
""" finalize the hash -- pad and hash remaining data
            returns hashval, the digest
        """ # we have already finalized so simply return the # previously calculated/stored hash value # pre-formatted padding data # copy nb. bits hash in total as a 64-bit BE word # copy nb. bits hash in total as a 128-bit BE word # size of block without the words at the end that count # the number of bits, 55 or 111. # Note: (((self.WORDBITS/8)*2)+1) equals ((self.WORDBITS>>2)+1) # special case of one padding byte # enough space to fill the block # use t=0 if no remaining data # NOT enough space, need 2 compressions #   ...add marker, pad with nulls and compress #   ...now pad w/nulls leaving space for marker & bit count # pad with zeroes # raise flag to set t=0 at the next _compress # append a marker byte # append the number of bits (long long)
self
data