Created
January 3, 2014 19:56
-
-
Save alexanderjeurissen/8245379 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public string pastelColorForString (string s) { | |
UInt32 hashCode = BitConverter.ToUInt32 ( | |
new SHA1CryptoServiceProvider ().ComputeHash ( | |
Encoding.UTF8.GetBytes (s) | |
),0 | |
); | |
return "#" + | |
((((hashCode >> 24) & 0xFF)+255)/2).ToString ("X") + | |
((((hashCode >> 16) & 0xFF)+255)/2).ToString ("X") + | |
((((hashCode >> 08) & 0xFF)+255)/2).ToString ("X"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment