Merge branch 'main' into feature/bots

This commit is contained in:
Jason Song
2022-11-29 11:09:20 +08:00
committed by GitHub
10 changed files with 36 additions and 31 deletions

View File

@@ -5,12 +5,12 @@ package base
import (
"crypto/sha256"
"fmt"
"encoding/hex"
"golang.org/x/crypto/pbkdf2"
)
func HashToken(token, salt string) string {
tempHash := pbkdf2.Key([]byte(token), []byte(salt), 10000, 50, sha256.New)
return fmt.Sprintf("%x", tempHash)
return hex.EncodeToString(tempHash)
}

View File

@@ -5,7 +5,7 @@ package v1_14 //nolint
import (
"crypto/sha256"
"fmt"
"encoding/hex"
"golang.org/x/crypto/argon2"
"golang.org/x/crypto/bcrypt"
@@ -53,7 +53,7 @@ func RecalculateUserEmptyPWD(x *xorm.Engine) (err error) {
tempPasswd = pbkdf2.Key([]byte(passwd), []byte(salt), 10000, 50, sha256.New)
}
return fmt.Sprintf("%x", tempPasswd)
return hex.EncodeToString(tempPasswd)
}
// ValidatePassword checks if given password matches the one belongs to the user.