feat: new hub service in hub

This commit is contained in:
2026-04-15 17:55:34 +03:00
parent 0b955bb714
commit 97e9458700
6 changed files with 85 additions and 33 deletions
+27
View File
@@ -0,0 +1,27 @@
package hasher
import (
"crypto/rand"
"crypto/sha256"
"encoding/hex"
"fmt"
"github.com/lorsanstand/HomeOps-Hub/internal/domain"
)
func newSalt(n int) ([]byte, error) {
b := make([]byte, n)
_, err := rand.Read(b)
return b, err
}
func MakeID(info domain.HostInfo, AgentName string) (string, error) {
salt, err := newSalt(10)
if err != nil {
return "", err
}
s := fmt.Sprintf("v1|host=%s|distro=%s|name=%s|", info.Hostname, info.Arch, AgentName)
h := sha256.Sum256(append([]byte(s), salt...))
return hex.EncodeToString(h[:16]), nil
}