use of edu.stanford.bmir.protege.web.shared.auth.MessageDigestAlgorithm in project webprotege by protegeproject.
the class UserIcon method getHue.
private static float getHue(String name) {
MessageDigestAlgorithm alg = new Md5DigestAlgorithmProvider().get();
alg.update(name.getBytes());
byte[] hash = alg.computeDigest();
BigInteger bi = new BigInteger(hash);
double percentageHue = Math.abs(bi.longValue() * 1.0 / Long.MAX_VALUE);
// Bound the value so that it's not a Red colour
double minHue = 25;
double maxHue = 340;
return (float) ((minHue + percentageHue * (maxHue - minHue)) / 360.0);
}
Aggregations