mirror of
https://github.com/ultrasn0w/huso.git
synced 2025-12-13 15:39:53 +01:00
27 lines
543 B
Go
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]
|
|
}
|