Skip to content

mkawserm/pasap

Repository files navigation

pasap

GoDoc Build Status Go Report Card Coverage Status


Package pasap provides a way to derive fixed length cryptographically secure secret key from password using different key derivation algorithm, provides an encoded string and verify the password against the encoded string

Usage

➜ go get github.com/mkawserm/pasap

package main

import "fmt"
import "github.com/mkawserm/pasap"

func main()  {
	a := pasap.NewArgon2idHasher()
	ec := &pasap.ByteBasedEncoderCredentials{
		Salt:     []byte("123456789"),
		Password: []byte("pass"),
	}
	secretKey, encodedKey, err := a.Encode(ec)

	if err != nil {
		panic(err)
	}

	fmt.Printf("Secret key: %v\n", secretKey)
	fmt.Printf("Encoded key: %v\n", encodedKey)

	vc := &pasap.ByteBasedVerifierCredentials{
		Password:   []byte("pass"),
		EncodedKey: encodedKey,
	}
	_, ok, err := a.Verify(vc)
	if err != nil {
		panic(err)
	}

	if ok {
		fmt.Println("Valid password")
	}
}

About

Secure password hash and secret key generator

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published