tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 
 Tools and Libs > Jodd > Commons > How to create Hash from Chars

How to create Hash from Chars 

Jodd is an open-source java library with lot of reusable components and feature rich utilities. This requires the library jodd-3.3.2.jar to be in classpath. The following example shows how to use HashCode.hash() API. It calculates the hash code from the given chars.

File Name  :  
com/bethecoder/tutorials/jodd/hash/HashFromCharsTest.java 
Author  :  Sudhakar KV
Email  :  kvenkatasudhakar@gmail.com
   
package com.bethecoder.tutorials.jodd.hash;

import jodd.util.HashCode;

public class HashFromCharsTest {

  /**
   @param args
   */
  public static void main(String[] args) {

    int seed = HashCode.SEED;
    int hashCode = HashCode.hash(seed, 'a');
    System.out.println(hashCode);

    hashCode = HashCode.hash(seed, 'Z');
    System.out.println(hashCode);
    
    hashCode = HashCode.hash(seed, new char [] { 'A',  'B''C' });
    System.out.println(hashCode);
    
    hashCode = HashCode.hash(seed, new char [] { 'x',  'y''z' });
    System.out.println(hashCode);
  }

}
   

It gives the following output,
6498
6491
8854463
8931848


                    Print

   



Books Recommendation

 
 
bl  br