Search in sources :

Example 1 with MessageDigestAlgorithm

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);
}
Also used : Md5DigestAlgorithmProvider(edu.stanford.bmir.protege.web.shared.auth.Md5DigestAlgorithmProvider) BigInteger(java.math.BigInteger) MessageDigestAlgorithm(edu.stanford.bmir.protege.web.shared.auth.MessageDigestAlgorithm)

Aggregations

Md5DigestAlgorithmProvider (edu.stanford.bmir.protege.web.shared.auth.Md5DigestAlgorithmProvider)1 MessageDigestAlgorithm (edu.stanford.bmir.protege.web.shared.auth.MessageDigestAlgorithm)1 BigInteger (java.math.BigInteger)1