Documentation
¶
Index ¶
Constants ¶
View Source
const (
// ROUNDS is the cost of rounds, minimum of 4, maximum of 31.
ROUNDS = 10
)
Variables ¶
View Source
var ErrEmptyField error = errors.New("function parameters must not be empty")
Functions ¶
func Hash ¶
Hash creates a PHC-formatted hash with config provided
import ( "fmt" "github.com/aldy505/phc-crypto/bcrypt" ) func main() { hash, err := bcrypt.Hash("password", bcrypt.Config{ Rounds: 12, }) if err != nil { fmt.Println(err) } fmt.Println(hash) // $bcrypt$v=0$r=12$$2432612431322479356256373563666e503557... }
func Verify ¶
Verify checks the hash if it's equal (by an algorithm) to plain text provided.
import ( "fmt" "github.com/aldy505/phc-crypto/bcrypt" ) func main() { hash := "$bcrypt$v=0$r=12$$2432612431322479356256373563666e503557..." verify, err := bcrypt.Verify(hash, "password") if err != nil { fmt.Println(err) } fmt.Println(verify) // true }
Types ¶
Click to show internal directories.
Click to hide internal directories.