Compute hex color code for an arbitrary string

Posted by user222164 on Stack Overflow See other posts from Stack Overflow or by user222164
Published on 2010-03-17T18:15:24Z Indexed on 2010/03/17 18:21 UTC
Read the original article Hit count: 161

Filed under:
|
|

Heading

Is there a way to map an arbitrary string to a HEX COLOR code. I tried to compute the HEX number for string using string hashcode. Now I need to convert this hex number to six digits which are in HEX color code range. Any suggestions ?

String [] programs = {"XYZ", "TEST1", "TEST2", "TEST3", "SDFSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS"};

for(int i = 0; i < programs.length; i++) {
  System.out.println( programs[i] + " -- " + Integer.toHexString(programs[i].hashCode()));
}

© Stack Overflow or respective owner

Related posts about color

Related posts about java