Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrAlgoNotSupported error = errors.New("the algorithm provided is not supported")
View Source
var ErrEmptyField error = errors.New("function parameters must not be empty")
Functions ¶
This section is empty.
Types ¶
type Algo ¶
Algo returns struct that will be use on Hash and Verify function
func Use ¶
Use initiates the hash/verify function. Available hash functions are: bcrypt, scrypt, argon2, pbkdf2. Please refer to each hash folder for configuration information.
import (
"fmt"
"github.com/flashydisch/phc-crypto"
)
func main() {
// Create a crypto instance
// Change the scope name to your prefered hashing algorithm
// Available options are: Bcrypt, Scrypt, Argon2, PBKDF2
crypto, err := phccrypto.Use(phccrypto.Scrypt, phccrypto.Config{})
hash, err := crypto.Hash("password123")
if err != nil {
fmt.Println(err)
}
fmt.Println(hash) // returns string ($scrypt$v=0$p=1,ln=32768,r=8$402ffb0b23cd3d3a$62daeae2ac...)
verify, err := crypto.Verify(hash, "password123")
if err != nil {
fmt.Println(err)
}
fmt.Println(verify) // returns boolean (true/false)
}
Click to show internal directories.
Click to hide internal directories.