package main

import (
	"crypto/sha256"
	"encoding/hex"
	"os"
)

func toHex(b []byte) string { return hex.EncodeToString(b) }

func fromHex(s string) ([]byte, error) {
	return hex.DecodeString(s)
}

func hostnameSafe() string {
	h, err := os.Hostname()
	if err != nil {
		return "unknown"
	}
	return h
}

func sha256Sum(b []byte) []byte {
	s := sha256.Sum256(b)
	return s[:]
}
