You've already forked openaccounting-server
mirror of
https://github.com/openaccounting/oa-server.git
synced 2025-12-09 00:50:59 +13:00
initial commit
This commit is contained in:
26
core/util/bcrypt.go
Normal file
26
core/util/bcrypt.go
Normal file
@@ -0,0 +1,26 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user