Skip to content

Instantly share code, notes, and snippets.

@Nikos410
Created March 18, 2026 15:21
Show Gist options
  • Select an option

  • Save Nikos410/071bc80a6f5e29440220c5d4c52b7f9a to your computer and use it in GitHub Desktop.

Select an option

Save Nikos410/071bc80a6f5e29440220c5d4c52b7f9a to your computer and use it in GitHub Desktop.
Generate a hex color based on some input text
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