Java Hash String hashCode(String sIn)

Here you can find the source of hashCode(String sIn)

Description

Return a hashcode as a positive Integer for a String.

In contrast to .hashCode(), this function returns a positive Integer.

License

Open Source License

Parameter

Parameter Description
sIn The String to get a hashcode for.

Return

The hashcode as a positive Integer in a String.

Declaration

public static String hashCode(String sIn) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from   w w w .j ava  2s.com
     * Return a hashcode as a positive Integer for a String.<p>
     *
     * In contrast to .hashCode(), this function returns a positive
     * Integer. This is helpful to use Strings as a unique key in
     * places (e.g. JavaScript) where you would be bothered by
     * special characters in the String.
     *
     * @param sIn The String to get a hashcode for.
     * @return The hashcode as a positive Integer in a String.
     */
    public static String hashCode(String sIn) {
        if (sIn == null) {
            return null;
        }

        return "" + Math.abs(sIn.hashCode());
    }
}

Related

  1. hashAlgToId(String hashAlg)
  2. hashArrayToString(int a[])
  3. hashbang(final String historyToken)
  4. hashcode(String name)
  5. hashCode(String s)
  6. hashCode(String str)
  7. hashCode1(String str)
  8. hashCode2(String str)
  9. hashCode64(String s)