Welcome to mirror list, hosted at ThFree Co, Russian Federation.

crypto.go « crypto « util - github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f600e7a60bb3b4661b9b3d03923fcb53efacf660 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package crypto

import (
	"golang.org/x/crypto/bcrypt"
)

func HashPasswordAsBcrypt(password string) (string, error) {
	hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
	return string(hash), err
}

func CheckPasswordHash(hash, password string) bool {
	err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
	return err == nil
}