You've already forked openaccounting-server
mirror of
https://github.com/openaccounting/oa-server.git
synced 2025-12-09 00:50:59 +13:00
27 lines
616 B
Go
27 lines
616 B
Go
package util
|
|
|
|
import (
|
|
"golang.org/x/crypto/bcrypt"
|
|
)
|
|
|
|
type Bcrypt interface {
|
|
GenerateFromPassword([]byte, int) ([]byte, error)
|
|
CompareHashAndPassword([]byte, []byte) error
|
|
GetDefaultCost() int
|
|
}
|
|
|
|
type StandardBcrypt struct {
|
|
}
|
|
|
|
func (bc *StandardBcrypt) GenerateFromPassword(password []byte, cost int) ([]byte, error) {
|
|
return bcrypt.GenerateFromPassword(password, cost)
|
|
}
|
|
|
|
func (bc *StandardBcrypt) CompareHashAndPassword(hashedPassword, password []byte) error {
|
|
return bcrypt.CompareHashAndPassword(hashedPassword, password)
|
|
}
|
|
|
|
func (bc *StandardBcrypt) GetDefaultCost() int {
|
|
return bcrypt.DefaultCost
|
|
}
|