Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
checksum colorizer
package main
import (
func repl1(hex []byte) []byte {
return []byte(fmt.Sprintf("\x1B[38;5;%dm%c%c\x1B[0m", hex[0] + 0x10*hex[1], hex[0], hex[1]))
func repl(line []byte) []byte {
hexet, _ := regexp.Compile("[0-9a-fA-F][0-9a-fA-F]")
return hexet.ReplaceAllFunc(line, repl1)
func main() {
hexets, _ := regexp.Compile("([^0-9a-zA-Z]|^|0x)([0-9a-fA-F][0-9a-fA-F])+([^0-9a-zA-Z]|$)")
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
line := scanner.Bytes()
line = hexets.ReplaceAllFunc(line, repl)
if err := scanner.Err(); err != nil {

This comment has been minimized.

Copy link
Owner Author

rain-1 commented Mar 18, 2019

go build then ; sha256sum * | ./foo. colors the hashes for easy comparison.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.