Calculate the certificate fingerprint - simply the SHA-512 hash of the DER-encoded certificate.
965366
public static String fingerprint( X509Certificate cert ) throws CertificateException
    {
        try
        {
            MessageDigest md = MessageDigest.getInstance( "SHA-512" );
            md.update( cert.getEncoded() );
            return ByteBufUtil.hexDump( md.digest() );
        }
        catch( NoSuchAlgorithmException e )
        {
            // SHA-1 not available
            throw new CertificateException( "Cannot use TLS on this platform, because SHA-512 message digest algorithm is not available: " + e.getMessage(), e );
        }
    }
711743
def fingerprint_from_raw_ssh_pub_key(key):
    
    fp_plain = hashlib.md5(key).hexdigest()
    return ':'.join(a + b for a, b in zip(fp_plain[::2], fp_plain[1::2]))
295188
def calculate_authentication_data(self, key):
        '''
        
        '''
        # This one is easy
        if self.key_id == KEY_ID_NONE:
            return ''

        # Determine the digestmod and how long the authentication data will be
        if self.key_id == KEY_ID_HMAC_SHA_1_96:
            digestmod = hashlib.sha1
            data_length = 20
        elif self.key_id == KEY_ID_HMAC_SHA_256_128:
            digestmod = hashlib.sha256
            data_length = 32
        else:
            raise ValueError('Unknown Key ID')

        # Fill the authentication data with the right number of zeroes
        # after storing the original first so we can restore it later
        current_authentication_data = self.authentication_data
        self.authentication_data = '\x00' * data_length

        # Build the packet
        msg = self.to_bytes()

        # Restore the authentication data
        self.authentication_data = current_authentication_data

        # Return the authentication data based on the generated packet
        # and the given key
        return hmac.new(key, msg, digestmod).digest()
581090
def get_fingerprint_from_public_key(pubkey):
    

    # TODO: why is there a tmpdir?
    with tempdir() as workdir:
        key = os.path.join(workdir, 'key.pub')
        with open(key, 'w') as fd:
            fd.write(pubkey)

        cmd = [
            'ssh-keygen',
            '-l',
            '-f', key,
        ]

        p = Subprocess(cmd)
        output = p.stdout.strip()
        bits, fingerprint, _ = output.split(' ', 2)
        return fingerprint
1288800
def to_payload
      version.htb << [depth].pack('C') << parent_fingerprint.htb <<
          [number].pack('N') << chain_code << [0x00].pack('C') << key.priv_key.htb
    end
1244275
def _calc_checksum(self, secret):
        
        return str_to_uascii(
            hashlib.sha256(mysql_aes_encrypt(self.salt, secret)).hexdigest()
        )
543547
static int getFingerprint(Method method) {
    int hashcode = method.getName().hashCode();
    hashcode =  hashcode + 31*method.getReturnType().getName().hashCode();
    for (Class<?> type : method.getParameterTypes()) {
      hashcode = 31*hashcode ^ type.getName().hashCode();
    }
    return hashcode;
  }
960548
def serialize_cert_to_der(cert_obj):
    
    return cert_obj.public_bytes(
        cryptography.hazmat.primitives.serialization.Encoding.DER
    )
1214046
def get_hash(self, keys=[]):
        """"""
        if not len(keys):
            keys = list(self.keys())

        string_rep = ''
        oself = self._ordered(deepcopy(self))
        for key in keys:
            string_rep += json.dumps(oself.get(key, ''), sort_keys=True)

        return hashlib.sha512(string_rep.encode()).hexdigest()[:16]
1139875
def calculate_hash(obj):
    

    hashable_fields = {
        'Chamber': ['name', 'country', 'abbreviation'],
        'Constituency': ['name'],
        'Group': ['name', 'abbreviation', 'kind', 'chamber'],
        'Mandate': ['group', 'constituency', 'role', 'begin_date', 'end_date',
            'representative']
    }

    fingerprint = hashlib.sha1()
    for field_name in hashable_fields[obj.__class__.__name__]:
        field = obj._meta.get_field(field_name)
        if field.is_relation:
            related = getattr(obj, field_name)
            if related is None:
                fingerprint.update(smart_str(related))
            else:
                fingerprint.update(related.fingerprint)
        else:
            fingerprint.update(smart_str(getattr(obj, field_name)))
    obj.fingerprint = fingerprint.hexdigest()
    return obj.fingerprint
1260552
public int getCertNum() {
        for (int i = this.certChain.length - 1; i >= 0; i--) {
            if (!this.certChain[i].getSubjectDN().equals(this.certChain[i].getIssuerDN())) {
                return i + 1;
            }
        }
        return this.certChain.length;
    }
609099
public static function calculateX509Fingerprint($x509cert, $alg = 'sha1')
    {
        assert('is_string($x509cert)');

        $arCert = explode("\n", $x509cert);
        $data = '';
        $inData = false;

        foreach ($arCert as $curData) {
            if (! $inData) {
                if (strncmp($curData, '-----BEGIN CERTIFICATE', 22) == 0) {
                    $inData = true;
                } elseif ((strncmp($curData, '-----BEGIN PUBLIC KEY', 21) == 0) || (strncmp($curData, '-----BEGIN RSA PRIVATE KEY', 26) == 0)) {
                    /* This isn't an X509 certificate. */
                    return null;
                }
            } else {
                if (strncmp($curData, '-----END CERTIFICATE', 20) == 0) {
                    break;
                }
                $data .= trim($curData);
            }
        }

        if (empty($data)) {
            return null;
        }

        $decodedData = base64_decode($data);

        switch ($alg) {
            case 'sha512':
            case 'sha384':
            case 'sha256':
                $fingerprint = hash($alg, $decodedData, false);
                break;
            case 'sha1':
            default:
                $fingerprint = strtolower(sha1($decodedData));
                break;
        }
        return $fingerprint;
    }
811093
def _get_concealed_token(self, token):
        
        enc_key = "%s:%s:%s" % (HASH_PATH_PREFIX, token, HASH_PATH_SUFFIX)
        return sha512(enc_key).hexdigest()
1326278
def info_hash(self):
        """"""
        info = self._struct.get('info')

        if not info:
            return None

        return sha1(Bencode.encode(info)).hexdigest()
436545
protected static String opensslHash(X509Certificate cert) {
        try {
            return openssl_X509_NAME_hash(cert.getSubjectX500Principal());
        }
        catch (Exception e) {
            throw new Error("MD5 isn't available!", e);
        }
    }
438990
protected ValidationResult getCachedResult(String certFingerprint) {

    CachedValidationResult cvr = validationResultsCache.get(certFingerprint);

    if (cvr == null)
      return null;

    if (!cachedValidationResultHasExpired(cvr, System.currentTimeMillis())) {
      return cvr.getResult();
    }

    validationResultsCache.remove(certFingerprint, cvr);
    return null;
  }
1033229
def thumbprint(self, hashalg=hashes.SHA256()):
        

        t = {'kty': self._params['kty']}
        for name, val in iteritems(JWKValuesRegistry[t['kty']]):
            if val.required:
                t[name] = self._key[name]
        digest = hashes.Hash(hashalg, backend=default_backend())
        digest.update(bytes(json_encode(t).encode('utf8')))
        return base64url_encode(digest.finalize())