2022-11-02 14:24:36 +05:30
|
|
|
// Copyright 2022 The Gitea Authors. All rights reserved.
|
2022-11-27 23:50:29 +05:30
|
|
|
// SPDX-License-Identifier: MIT
|
2022-11-02 14:24:36 +05:30
|
|
|
|
|
|
|
package base
|
|
|
|
|
|
|
|
import (
|
2022-11-28 16:49:18 +05:30
|
|
|
"encoding/hex"
|
2022-11-02 14:24:36 +05:30
|
|
|
|
2023-02-23 00:51:46 +05:30
|
|
|
"github.com/minio/sha256-simd"
|
2022-11-02 14:24:36 +05:30
|
|
|
"golang.org/x/crypto/pbkdf2"
|
|
|
|
)
|
|
|
|
|
|
|
|
func HashToken(token, salt string) string {
|
|
|
|
tempHash := pbkdf2.Key([]byte(token), []byte(salt), 10000, 50, sha256.New)
|
2022-11-28 16:49:18 +05:30
|
|
|
return hex.EncodeToString(tempHash)
|
2022-11-02 14:24:36 +05:30
|
|
|
}
|