Paperchain is a blockchain-based distributed application for taking contemporaneous notes that are cryptographically verifiable.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
499 B

package utils
import (
"encoding/hex"
"fmt"
"log"
"github.com/joho/godotenv"
"lukechampine.com/blake3"
)
func LoadEnv() map[string]string {
var env map[string]string
env, err := godotenv.Read()
if err != nil {
log.Fatal("Error loading .env file")
}
return env
}
func Hash(data string) string {
h := blake3.New(32, nil)
_, _ = h.Write([]byte(data))
return hex.EncodeToString(h.Sum(nil))
}
func HashStruct(data PcData) string {
str := fmt.Sprintf("%+v", data)
return Hash(str)
}