Android/Java: Convert any string to color (hex)

android, java

Solution

the `String.hashCode()` will return an int value, so then it's just a matter of turning that into into a hex value.

String s = "Home";
String color = String.format("#%X", s.hashCode());

Problem

Is there any way to generate a color from any String in Java / Android like an Encrypt / Hash function? Example: The String "Home" generates a color like "#FF1234". The String "Sky" generates a color like "#00CC33" ... Without randomize. So, the system will always calculate the same colors for that strings Thanks EDIT: The Strings are freely defined by the user

Original source