finalize the hash -- pad and hash remaining data
            returns hashval, the digest
326152
def final(self, data=''):
        
        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
635413
private void calculateCalendarHashChainOutput() throws KSIException {
        ChainResult lastRes = null;
        for (AggregationHashChain chain : aggregationChains) {
            if (lastRes == null) {
                lastRes = chain.calculateOutputHash(0L);
            } else {
                lastRes = chain.calculateOutputHash(lastRes.getLevel());
            }
            LOGGER.debug("Output hash of chain: {} is {}", chain, lastRes.getOutputHash());
        }
    }
111199
def digest_packets(packets, hasher):
    """"""
    data_to_hash = io.BytesIO()
    for p in packets:
        data_to_hash.write(p['_to_hash'])
    hasher.update(data_to_hash.getvalue())
    return hasher.digest()
784775
def digest(self):
        

        A = self.A
        B = self.B
        C = self.C
        D = self.D
        input = [] + self.input
        count = [] + self.count

        index = (self.count[0] >> 3) & 0x3fL

        if index < 56:
            padLen = 56 - index
        else:
            padLen = 120 - index

        padding = ['\200'] + ['\000'] * 63
        self.update(padding[:padLen])

        # Append length (before padding).
        bits = _bytelist2long(self.input[:56]) + count

        self._transform(bits)

        # Store state in digest.
        digest = _long2bytes(self.A << 96, 16)[:4] + \
                 _long2bytes(self.B << 64, 16)[4:8] + \
                 _long2bytes(self.C << 32, 16)[8:12] + \
                 _long2bytes(self.D, 16)[12:]

        self.A = A 
        self.B = B
        self.C = C
        self.D = D
        self.input = input 
        self.count = count 

        return digest
1169913
def hash_block
      hash_string = [index,timestamp,data,prev_hash].join
      sha = Digest::SHA256.new
      sha.update(hash_string)
      sha.hexdigest
    end
242761
def _sighash_final_hashing(self, copy_tx, sighash_type):
        '''
        
        '''
        sighash = ByteData()
        sighash += copy_tx.to_bytes()
        sighash += utils.i2le_padded(sighash_type, 4)

        return utils.hash256(sighash.to_bytes())
1339995
def hash_token(token, salt):
    '''
    
    '''
    digest = hashes.Hash(sha(), backend=default_backend())
    digest.update(binascii.unhexlify(token))
    digest.update(binascii.unhexlify(salt))
    return binascii.hexlify(digest.finalize()).decode()
474960
function (digest, iterationCount) {

        var derive = function (password, salt, len) {
            var key, i, tmpBuf;
            if (len > digest.digestLength()) {
                throw "Key length larger than digest length";
            }
            digest.reset();
            digest.update(password);
            digest.update(salt);
            tmpBuf = digest.finalize();
            for (i = 1; i < iterationCount; i++) {
                tmpBuf = digest.digest(tmpBuf);
            }
            return tmpBuf.slice(0, len);
        };

        return {
            deriveKey: function (password, salt, len) {
                return derive(convertToUint8Array(password), convertToUint8Array(salt), len);
            }
        };
    }
511395
public String getAvatarHash() {
        byte[] bytes = getAvatar();
        if (bytes == null) {
            return null;
        }

        MessageDigest digest;
        try {
            digest = MessageDigest.getInstance("SHA-1");
        }
        catch (NoSuchAlgorithmException e) {
            LOGGER.log(Level.SEVERE, "Failed to get message digest", e);
            return null;
        }

        digest.update(bytes);
        return StringUtils.encodeHex(digest.digest());
    }
929930
@SuppressWarnings("unused")
    void finish(String hash) {
        TokenInfo info = new TokenInfo();
        String error = null;
        String errorDesc = "";
        String errorUri = "";

        // Iterate over keys and values in the string hash value to find relevant
        // information like the access token or an error message. The string will be
        // in the form of: #key1=val1&key2=val2&key3=val3 (etc.)
        int idx = 1;
        while (idx < hash.length() - 1) {
            // Grab the next key (between start and '=')
            int nextEq = hash.indexOf('=', idx);
            if (nextEq < 0) {
                break;
            }
            String key = hash.substring(idx, nextEq);

            // Grab the next value (between '=' and '&')
            int nextAmp = hash.indexOf('&', nextEq);
            nextAmp = nextAmp < 0 ? hash.length() : nextAmp;
            String val = hash.substring(nextEq + 1, nextAmp);

            // Start looking from here from now on.
            idx = nextAmp + 1;

            // Store relevant values to be used later.
            if (key.equals("access_token")) {
                info.setAccessToken(val);
            } else if (key.equals("token_type")) {
                info.setTokenType(val);
            } else if (key.equals("expires_in")) {
                // expires_in is seconds, convert to milliseconds and add to now
                Double expiresIn = Double.valueOf(val) * 1000;
                info.setExpires(String.valueOf(clock.now() + expiresIn));
            } else if (key.equals("error")) {
                error = val;
            } else if (key.equals("error_description")) {
                errorDesc = " (" + val + ")";
            } else if (key.equals("error_uri")) {
                errorUri = "; see: " + val;
            }
        }

        if (error != null) {
            lastCallback.onFailure(
                    new RuntimeException("Error from provider: " + error + errorDesc + errorUri));
        } else if (info.getAccessToken() == null) {
            lastCallback.onFailure(new RuntimeException("Could not find access_token in hash " + hash));
        } else {
            setToken(lastRequest, info);
            lastCallback.onSuccess(info);
        }
    }
549309
public byte[] digest() {
    byte[] result = new byte[20];
    
    finalBuffer.put((byte)0x80);
    if(finalBuffer.remaining() < 8) {
      while(finalBuffer.remaining() > 0) {
        finalBuffer.put((byte)0);
      }
      finalBuffer.position(0);
      transform(finalBuffer);
      finalBuffer.position(0);
    }
    
    while(finalBuffer.remaining() > 8) {
      finalBuffer.put((byte)0);
    }
    
    finalBuffer.putLong(length << 3);
    finalBuffer.position(0);
    transform(finalBuffer);
    
    finalBuffer.position(0);
    finalBuffer.putInt(h0);
    finalBuffer.putInt(h1);
    finalBuffer.putInt(h2);
    finalBuffer.putInt(h3);
    finalBuffer.putInt(h4);    
    finalBuffer.position(0);
    
    for(int i  = 0 ; i < 20 ; i++) {
     result[i] = finalBuffer.get(); 
    }
    
    return result;
  }
789941
def to_hash
      result = {
        name: @name,
        value: @value,
        domain: @domain,
        path: @path,
        created_at: @created_at
      }
      {
        expiry: @expiry,
        secure: (true if @secure),
        http_only: (true if @http_only),
        version: (@version if version != 0),
        comment: @comment,
        comment_url: @comment_url,
        discard: (true if @discard),
        ports: @ports
      }.each do |name, value|
        result[name] = value if value
      end

      result
    end
384102
public static long createHash(byte[] data) {
        long h = 0;
        byte[] res;

        synchronized (digestFunction) {
            res = digestFunction.digest(data);
        }

        for (int i = 0; i < 4; i++) {
            h <<= 8;
            h |= ((int) res[i]) & 0xFF;
        }
        return h;
    }
213991
def hash(self):
        '''
        
        '''
        hashed = super(Trunc, self).hash()
        return khash(hashed, self._max_size)
234507
def hash(self):
        """"""
        if 'digest' not in self._p4dict:
            self._p4dict = self._connection.run(['fstat', '-m', '1', '-Ol', self.depotFile])[0]

        return self._p4dict['digest']
1276388
def finalize(self):
        
        self._check_finalized()
        self._final = True

        for dest_w, values in self.dest_instrs_info.items():
            mux_vals = dict(zip(self.instructions, values))
            dest_w <<= sparse_mux(self.signal_wire, mux_vals)
1049011
private byte[] resetAndRepeatDigest(byte[] digestData) {
		final int digestCount = Math.max(1, this.digestCount);
		reset();
		for (int i = 0; i < digestCount - 1; i++) {
			digestData = doDigest(digestData);
			reset();
		}
		return digestData;
	}