feat(sol): UDP + HTTP listener

This commit is contained in:
Björn Benouarets
2025-11-11 17:19:49 +01:00
commit 8ed56f7ba0
12 changed files with 565 additions and 0 deletions

35
auth/auth.go Normal file
View File

@@ -0,0 +1,35 @@
package auth
import (
"crypto/sha256"
"encoding/hex"
"fmt"
)
// Authenticator handles authentication
type Authenticator struct {
user string
password string
hash string
}
// New creates a new authenticator with the given credentials
func New(username, password string) *Authenticator {
authString := fmt.Sprintf("%s:%s", username, password)
hash := sha256.Sum256([]byte(authString))
hashStr := hex.EncodeToString(hash[:])
return &Authenticator{
user: username,
password: password,
hash: hashStr,
}
}
// Verify checks if the provided username and password are valid
func (a *Authenticator) Verify(username, password string) bool {
authString := fmt.Sprintf("%s:%s", username, password)
hash := sha256.Sum256([]byte(authString))
hashStr := hex.EncodeToString(hash[:])
return hashStr == a.hash
}