Initial DDC release

This commit is contained in:
SirBlob committed 2026-10-25 20:24:50 -04:00
commit 434f6441da
57 files changed
+4606

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
package auth
import (
"crypto/sha256"
"crypto/subtle"
)
func CredentialsMatch(expectedUsername, expectedPassword, username, password string) bool {
usernameMatches := constantTimeEqual(expectedUsername, username)
passwordMatches := constantTimeEqual(expectedPassword, password)
return usernameMatches && passwordMatches
}
func constantTimeEqual(expected, actual string) bool {
expectedHash := sha256.Sum256([]byte(expected))
actualHash := sha256.Sum256([]byte(actual))
return subtle.ConstantTimeCompare(expectedHash[:], actualHash[:]) == 1
}