MCPcopy Create free account
hub / github.com/bytebase/bytebase / hashEmailCode

Method hashEmailCode

backend/api/v1/auth_service.go:1619–1623  ·  view source on GitHub ↗

hashEmailCode returns HMAC-SHA256(code) hex-encoded, keyed with the server's auth secret. HMAC with a server-side secret (vs. bare SHA-256) prevents offline brute force of the 10^6-size code space if the DB is ever compromised — the attacker would also need the auth secret to verify candidate codes.

(code string)

Source from the content-addressed store, hash-verified

1617// 10^6-size code space if the DB is ever compromised — the attacker would also need the
1618// auth secret to verify candidate codes.
1619func (s *AuthService) hashEmailCode(code string) string {
1620 mac := hmac.New(sha256.New, []byte(s.secret))
1621 mac.Write([]byte(code))
1622 return hex.EncodeToString(mac.Sum(nil))
1623}
1624
1625// SendEmailLoginCode sends a 6-digit verification code. Always returns success
1626// (no email enumeration). Rate limit: 60-sec resend cooldown enforced atomically

Callers 2

verifyEmailCodeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected