Documentation ¶
Index ¶
Constants ¶
View Source
const ( // KEYLEN is how many bytes to generate as output. KEYLEN = 32 // COST is the iterations count (affects memory and CPU usage). // Minimum for interactive login: 16384. // Ideal for file encryption: 1048576. COST = 32768 // ROUNDS is the block size (affects memory and CPU usage). ROUNDS = 8 // PARALLELISM is the parallelism factor (threads to run in parallel - affects the memory, CPU usage). PARALLELISM = 1 // SALT_LENGTH is the default salth length in bytes. SALT_LENGTH = 16 )
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/scrypt" ) func main() { hash, err := scrypt.Hash("password", scrypt.Config{ Parallelism: 3, }) if err != nil { fmt.Println(err) } fmt.Println(hash) // $scrypt$v=0$p=3,ln=32768,r=8$64ecb15ec1aa81bc403a892efb2289ce$4fc8d3bc... }
func Verify ¶
Verify checks the hash if it's equal (by an algorithm) to plain text provided.
import ( "fmt" "github.com/aldy505/phc-crypto/scrypt" ) func main() { hash := "$scrypt$v=0$p=3,ln=32768,r=8$64ecb15ec1aa81bc403a892efb2289ce$4fc8d3bc..." verify, err := scrypt.Verify(hash, "password") if err != nil { fmt.Println(err) } fmt.Println(verify) // true }
Types ¶
Click to show internal directories.
Click to hide internal directories.