Files
huso/rechner.go
2022-04-15 12:13:23 +02:00

27 lines
543 B
Go

package main
import (
"crypto/sha512"
"encoding/binary"
"fmt"
"strconv"
)
func Sauce(malid int64, username string) string {
return fmt.Sprintf("%x", sha512.Sum512([]byte(registerSecret+strconv.FormatInt(malid, 10)+username)))
}
func BytesToInt64(bytes []byte) (int64, error) {
yes, c := binary.Varint(bytes)
if c <= 0 {
return yes, fmt.Errorf("int64 decode error: %s", bytes)
}
return yes, nil
}
func Int64ToByte(yes int64) []byte {
buf := make([]byte, binary.MaxVarintLen64)
n := binary.PutVarint(buf, yes)
return buf[:n]
}