I want to convert a string to a colorhexcode in JavaScript or php.
Is there a way to do that? The strings look like dfc6d9ff5a1d394e or
2b514f260aad317a.
The background is that these are unique ids and I want to convert them to unique colours…
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If these IDs are reasonably random, ie: part of a hash or UUID try:
or if they are somewhat more uniform and you’d like something a bit more ‘random’ without actually being random:
or if you want to get fancier here’s a previous answer with more in-depth code.