feat: first working version

This commit is contained in:
nihonium 2026-01-14 12:55:21 +03:00
parent a67e208d6e
commit 1029563cb1
11 changed files with 585 additions and 0 deletions

26
internal/utils/hash.go Normal file
View file

@ -0,0 +1,26 @@
package utils
import (
"crypto/sha256"
"encoding/hex"
)
/**
* @brief Вычислить SHA-256 хеш пароля
* @param password Строка с паролем
* @return Хеш в виде строки HEX
*/
func HashPassword(password string) string {
hash := sha256.Sum256([]byte(password))
return hex.EncodeToString(hash[:])
}
/**
* @brief Проверить совпадение пароля и хеша
* @param password Введённый пароль
* @param hash Хеш пароля из БД
* @return true если совпадает
*/
func CheckPassword(password, hash string) bool {
return HashPassword(password) == hash
}