Created
March 18, 2026 15:21
-
-
Save Nikos410/071bc80a6f5e29440220c5d4c52b7f9a to your computer and use it in GitHub Desktop.
Generate a hex color based on some input text
This file contains hidden or 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
| import java.util.UUID; | |
| import static java.nio.charset.StandardCharsets.UTF_8; | |
| class Scratch { | |
| public static void main(String[] args) { | |
| final String input = | |
| """ | |
| Some random input value that should always generate the same color | |
| This can have multiple lines! | |
| """; | |
| final String uuid = | |
| UUID.nameUUIDFromBytes(input.getBytes(UTF_8)).toString(); | |
| final String hexColor = "#" + uuid.substring(uuid.length() - 6); | |
| System.out.println(hexColor); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment