Полная зачистка legacy + закрытие fix24.1/fix24.2 + обновление логотипа
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"crypto/hmac"
|
||||
"crypto/sha256"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
@@ -42,3 +44,22 @@ func VerifyPassword(password string, storedHash string) (ok bool, legacy bool) {
|
||||
}
|
||||
return SHA224String(password) == storedHash, true
|
||||
}
|
||||
|
||||
func HmacSHA256Hex(payload string, secret string) string {
|
||||
mac := hmac.New(sha256.New, []byte(secret))
|
||||
mac.Write([]byte(payload))
|
||||
sum := mac.Sum(nil)
|
||||
str := ""
|
||||
for _, v := range sum {
|
||||
str += fmt.Sprintf("%02x", v)
|
||||
}
|
||||
return str
|
||||
}
|
||||
|
||||
func PeerSecretDigest(rawSecret string) string {
|
||||
secretKey := strings.TrimSpace(os.Getenv("HY2XS_PEER_SECRET_KEY"))
|
||||
if secretKey == "" {
|
||||
secretKey = "hy2xs-peer-secret-key"
|
||||
}
|
||||
return HmacSHA256Hex(rawSecret, secretKey)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user