Compute a cryptographic hash of the information in this policy; helps
 callers compare two policies to see if they are equivalent.
 @see https://github.com/rightscale/cmaro/domain/login_policy.go
332657
def fingerprint
      h = Digest::SHA2.new
      h << (self.exclusive ? 'true' : 'false')

      users = self.users.sort { |a, b| a.uuid <=> b.uuid }
      users.each do |u|
        h << format(",(%d,%s,%s,%d,%s",
                    u.uuid, u.common_name,
                    (u.superuser ? 'true' : 'false'),
                    (u.expires_at ? u.expires_at.to_i : 0),
                    u.username)

        u.public_key_fingerprints.each do |fp|
          h << "," << fp
        end
        h << ')'
      end

      h.hexdigest
    end
140449
def verify_hash(self, hashed_data, compare_data):
        
        return self.security.hashing_context.verify(
            encode_string(compare_data), hashed_data)
333412
public static String computePasswordHash(final String password, final byte[] salt) {
    if (StringMan.isEmpty(password))
      return (StringMan.encodeBytesToString(salt));
    final KeySpec spec = new PBEKeySpec(password.toCharArray(), salt, 2048, 160);
    SecretKeyFactory f;
    try {
      f = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
      final byte[] hash = f.generateSecret(spec).getEncoded();
      return StringMan.encodeBytesToString(hash);
    } catch (final NoSuchAlgorithmException ex) {
      throw new RuntimeException("Missing encryption algorithm:", ex);
    } catch (final InvalidKeySpecException ex) {
      throw new RuntimeException("Key spec is incorrect.", ex);
    }
  }
1329637
public static byte[] getHashedPassword(ClientAuthScheme scheme, String password) {
        if (password == null) {
            return null;
        }

        MessageDigest md = null;
        try {
            md = MessageDigest.getInstance(ClientAuthScheme.getDigestScheme(scheme));
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            System.exit(-1);
        }
        byte hashedPassword[] = null;
        hashedPassword = md.digest(password.getBytes(Constants.UTF8ENCODING));
        return hashedPassword;
    }
612059
function P_hash(secret, seed, outputLength, algorithm) {
    let result = Buffer.alloc(0); // empty buffer
    let hmac;

    // for the initial iteration, set the (initial) data to our seed
    let data = seed;
    while (result.length < outputLength) {
        // calculate the hmac for our current 'data' value (our seed on the initiatial iteration...or an iterative hmac of that seed in later iterations)
        hmac = exports.crypto.createHmac(algorithm, secret).update(data).digest();
        // save this hmac result as the 'data' input for the next iteration
        let dataForNextIteration = hmac;
        // concatenate the hmac and our seed
        data = Buffer.concat([hmac, seed]);
        // calculate an hmac for the hmac-plus-seed (which we will store in our output)
        hmac = exports.crypto.createHmac(algorithm, secret).update(data).digest();
        // add the hmac to our result
        result = Buffer.concat([result, hmac]);
        // restore the saved first-interation-stage hmac as the 'data' input for our next iteration
        data = dataForNextIteration;
    }

    // if our HMAC's output block size resulted in a length which is slightly too big, discard the extra bytes.
    if (result.length > outputLength) {
        let truncatedBuffer = Buffer.alloc(outputLength);
        result.copy(truncatedBuffer, 0, 0, outputLength);
        result = truncatedBuffer;
    }

    // return the hash result (with the number of octects/bytes specified as 'outputLength' by the caller)
    return result;
}
4615
static int hash(double d) {
		long bits = Double.doubleToLongBits(d);
		int hc = (int) (bits ^ (bits >>> 32));
		return hash(hc);
	}
358788
private static int hash(Object x, int length) {
        int h = System.identityHashCode(x);
        // Multiply by -127, and left-shift to use least bit as part of hash
        return ((h << 1) - (h << 8)) & (length - 1);
    }
1353600
def id_hash(id, organization)
      {
        id: id,
        provider: organization.oauth_provider,
        realm: organization.oauth_uid
      }
    end
896859
def key?
      # => We store a SHA512 Hex Digest of the Key
      return false unless Config.query_params['auth_key']
      Digest::SHA512.hexdigest(Config.query_params['auth_key']) == auth['auth_key']
    end
942016
function computeLedgerHash(ledgerHeader) {
  var prefix = hashprefixes.HASH_LEDGER.toString(16).toUpperCase();
  return hash(prefix +
    intToHex(ledgerHeader.ledger_index, 4) +
    bigintToHex(ledgerHeader.total_coins, 8) +
    ledgerHeader.parent_hash +
    ledgerHeader.transaction_hash +
    ledgerHeader.account_hash +
    intToHex(ledgerHeader.parent_close_time, 4) +
    intToHex(ledgerHeader.close_time, 4) +
    intToHex(ledgerHeader.close_time_resolution, 1) +
    intToHex(ledgerHeader.close_flags, 1)
  );
}
684392
private Sha256Hash calculateHash() {
        try {
            ByteArrayOutputStream bos = new UnsafeByteArrayOutputStream(HEADER_SIZE);
            writeHeader(bos);
            return Sha256Hash.wrapReversed(Sha256Hash.hashTwice(bos.toByteArray()));
        } catch (IOException e) {
            throw new RuntimeException(e); // Cannot happen.
        }
    }
647076
public static String computeEtag(long lastModification, ApplicationConfiguration configuration, Crypto crypto) {
        boolean useEtag = configuration.getBooleanWithDefault(HTTP_USE_ETAG,
                HTTP_USE_ETAG_DEFAULT);
        if (!useEtag) {
            return null;
        }
        String raw = Long.toString(lastModification);
        return crypto.hexSHA1(raw);
    }
1070442
private static int computeChecksum(byte[] buf, int offset, int length, String channel) {
        Hasher hasher = Hashing.murmur3_32().newHasher();
        hasher.putBytes(buf, offset, length);
        hasher.putUnencodedChars(channel);
        return hasher.hash().asInt() & 0xffff;
    }
418645
@Override
    public byte[] getUserSessionKey ( CIFSContext tc, byte[] chlng ) {
        if ( this.hashesExternal ) {
            return null;
        }
        return super.getUserSessionKey(tc, chlng);
    }
844404
function passwordVerify($password, $hash) {
        if (!function_exists('crypt')) {
            trigger_error("Crypt must be loaded for password_verify to function", E_USER_WARNING);
            return false;
        }
        $ret = crypt($password, $hash);
        if (!is_string($ret) || $this->_strlen($ret) != $this->_strlen($hash) || $this->_strlen($ret) <= 13) {
            return false;
        }

        $status = 0;
        for ($i = 0; $i < $this->_strlen($ret); $i++) {
            $status |= (ord($ret[$i]) ^ ord($hash[$i]));
        }

        return $status === 0;
    }
1314828
@Override
    public byte[] getUnicodeHash ( CIFSContext tc, byte[] chlng ) throws GeneralSecurityException {
        if ( this.hashesExternal ) {
            return this.unicodeHash;
        }
        return super.getUnicodeHash(tc, chlng);
    }
304191
function hashPassword (passport, next) {
  if (passport.password) {
    bcrypt.hash(passport.password, 10, function (err, hash) {
      passport.password = hash;
      next(err, passport);
    });
  } else {
    next(null, passport);
  }
}