leo
f129606b8f
All checks were successful
continuous-integration/drone/push Build is passing
* add handlers for signin,singup,logout... * introduce ent ORM and add user schema * add live mode, devel mode to selectively turn on features via config/flags * add templates, handle embedding moar smarter: * live mode uses live folder structure, else embedded templates are used * start using tailwindcss to style stuff * add development goodies for hot-reloading (browser-sync - bs.js) * pimp-up config.dhall with actual custom config Type (enables remote schema and local values only as needed) * add justfile (alternative to makefile for process automation)
26 lines
566 B
Go
26 lines
566 B
Go
package password
|
|
|
|
import "golang.org/x/crypto/bcrypt"
|
|
|
|
func GetHash(password string) ([]byte, error) {
|
|
// NOTE: bcrypt will not operate on passwords longer than 72 characters.
|
|
hash, err := bcrypt.GenerateFromPassword(
|
|
[]byte(password), bcrypt.DefaultCost,
|
|
)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return hash, nil
|
|
}
|
|
|
|
func Compare(oldHash []byte, password string) bool {
|
|
// NOTE: bcrypt will not operate on passwords longer than 72 characters.
|
|
err := bcrypt.CompareHashAndPassword(oldHash, []byte(password))
|
|
if err != nil {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|