Documentation ¶
Overview ¶
Package argon2 provides argon2id hash function which satisfies the hash.Hash interface
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ID ¶
ID creates a new Argon2ID hash.Hash
It uses Argon2's recommended defaults. if you want to use custom argon parameters use argon2.New()
Example ¶
package main import ( "fmt" "github.com/go-compile/rome/argon2" ) func main() { // import "github.com/go-compile/rome/argon2" salt := []byte("dangerous-example-salt") // Here is a real world example of what you should do instead // salt := make([]byte, 16) // _, err := rand.Read(salt) // if err != nil { // panic(err) // } h := argon2.ID(salt) h.Write([]byte("12345")) h.Write([]byte(".....")) digest := h.Sum(nil) // if your salt isn't constant make sure to prepend it to the // digest fmt.Printf("%x\n", digest) }
Output: 9e200b0b4a7eb363be8f314733da18b2e7d9afa552a30e1bf57869786faf4125
func NewID ¶
NewID creates a hash.Hash for Argon2ID
Example ¶
package main import ( "fmt" "github.com/go-compile/rome/argon2" ) func main() { // import "github.com/go-compile/rome/argon2" salt := []byte("dangerous-example-salt") // Here is a real world example of what you should do instead // salt := make([]byte, 16) // _, err := rand.Read(salt) // if err != nil { // panic(err) // } // specify your own argon2id parameters h := argon2.NewID(salt, 1, 20, 1, 64) h.Write([]byte("12345")) h.Write([]byte(".....")) digest := h.Sum(nil) // if your salt isn't constant make sure to prepend it to the // digest fmt.Printf("%x\n", digest) }
Output: 13ecf23484ce58153dc0dbae3a0a1f034596abe353a60f68f9441f39952178adab4c85e14704edf73d4910b7027f7565210c28e00832293cea524fe66a5b9137
Types ¶
type Argon2id ¶
type Argon2id struct {
// contains filtered or unexported fields
}
Argon2id is a hash.Hash
func (*Argon2id) BlockSize ¶
BlockSize returns the hash's underlying block size. The Write method must be able to accept any amount of data, but it may operate more efficiently if all writes are a multiple of the block size.
Click to show internal directories.
Click to hide internal directories.