Files
nixcn-cms/internal/cryptography/bcrypt.go
Asai Neko 63f71d3b81
Some checks failed
Build Backend (NixCN CMS) TeamCity build failed
Build Frontend (NixCN CMS) TeamCity build finished
Add bcrypt and aes crypto lib
Signed-off-by: Asai Neko <sugar@sne.moe>
2026-01-01 14:24:41 +08:00

23 lines
410 B
Go

package cryptography
import "golang.org/x/crypto/bcrypt"
func BcryptHash(input string) (string, error) {
hash, err := bcrypt.GenerateFromPassword(
[]byte(input),
bcrypt.DefaultCost,
)
if err != nil {
return "", err
}
return string(hash), nil
}
func BcryptVerify(input string, hashed string) bool {
err := bcrypt.CompareHashAndPassword(
[]byte(hashed),
[]byte(input),
)
return err == nil
}