Code example for HashFunction

Methods: hashString

0
     * @param strToHash 
     * @return the {@code ObjectId} generated from the string 
     */ 
    public static ObjectId forString(final String strToHash) {
        Preconditions.checkNotNull(strToHash);
        HashCode hashCode = HASH_FUNCTION.hashString(strToHash, Charset.forName("UTF-8"));
        return new ObjectId(hashCode.asBytes(), false);
    } 
 
    /** 
     * Returns the value of this ObjectId's internal hash at the given index without having to go 
     * through {@link #getRawValue()} and hence create excessive defensive copies of the byte array. 
     *  
     * @param index the index of the byte inside this objectid's internal hash to return 
     * @return the byte at the given index as an integer 
     */ 
    public int byteN(int index) {
        int b = this.hashCode[index] & 0xFF;
        return b;
    } 
Experience pair programming with AI  Get Codota for Java