12345678910111213141516171819202122232425 |
- package internals
- import (
- "golang.org/x/crypto/bcrypt"
- )
- type Crypt struct {
- initialized bool
- }
- func NewCrypt() *Crypt {
- return &Crypt{initialized: true}
- }
- func (c *Crypt) HashPassword(password string) (string, error) {
- appended_password := password
- bytes, err := bcrypt.GenerateFromPassword([]byte(appended_password), 14)
- return string(bytes), err
- }
- func (c *Crypt) CheckPasswordHash(password string, hash string) error {
- appended_password := password
- return bcrypt.CompareHashAndPassword([]byte(hash), []byte(appended_password))
- }
|