Documentation
¶
Index ¶
Constants ¶
View Source
const ( // KEY_LENGTH is the desired number of returned bytes KEY_LENGTH = 64 // TIME is the number of iterations to perform TIME = 16 // MEMORY is the a mount of memory (in kilobytes) to use MEMORY = 64 * 1024 // PARALLELISM is the degree of parallelism (i.e. number of threads) PARALLELISM = 4 // DEFAULT_VARIANT combines the Argon2d and Argon2i DEFAULT_VARIANT = ID // SALT_LENGTH is the default salth length in bytes. SALT_LENGTH = 32 )
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
package main import ( "fmt" "github.com/aldy505/phc-crypto/argon2" ) func main() { hash, err := argon2.Hash("password", argon2.Config{ Parallelism: 3, Variant: argon2.I, }) if err != nil { fmt.Println(err) } fmt.Println(hash) // $argon2i$v=19$m=65536,t=16,p=3$8400b4e5f01f30092b794de34c61a6fdfea6b6b446560fda08a876bd11e9c62e$3fd77927d189... }
func Verify ¶
Verify checks the hash if it's equal (by an algorithm) to plain text provided.
package main import ( "fmt" "github.com/aldy505/phc-crypto/argon2" ) func main() { hash := "$argon2i$v=19$m=65536,t=16,p=3$8400b4e5f01f30092b794de34c61a6fdfea6b6b446560fda08a876bd11e9c62e$3fd77927d189..." verify, err := argon2.Verify(hash, "password") if err != nil { fmt.Println(err) } fmt.Println(verify) // true }
Types ¶
Click to show internal directories.
Click to hide internal directories.