~eau/passwd

0068bf3e98ab02a543618b138637e939bdc3ca83 — eau 5 years ago 206ca02
README updates? :)
1 files changed, 38 insertions(+), 26 deletions(-)

M README.md
M README.md => README.md +38 -26
@@ 103,46 103,58 @@ create a password hashing object with *Argon2* default profile:
	}
	// hashed value: $2id$GlQX3F.KSYw1JLVv.LKDT.$1$65536$8$32$97DO7W9m/I8CTEQFKDa.VvEBTX1WepVv4qaWlt0OqH6

done.


## Password Compare (public parameters / bcrypt) :
## Password Compare (non-masked parameters / non-key'ed / bcrypt) :

check a hash against a password:   

**`err := passwd.Compare(hashed, []byte("password"))`**  

done, `err` will be nil if the password matches the hash.     



	err := passwd.Compare(hashed, []byte("password"))
	if err != nil {
		// handle error
	}


## Password Hashing (**masked parameters**):

create a password hashing profile:   

**`p, err := passwd.NewMasked(passwd.Argon2idDefault)`**     



Hash your password:   

**`hashed, err := p.Hash( []byte("my1337p4ssw0rd!") )`**

done, that's it, now **`hashed`** contain the hashed password and parameters are
masked. 
	p, err := passwd.NewMasked(passwd.Argon2idDefault)
	if err != nil {
		// handle error
	}
	
	hashed, err := p.Hash( []byte("my1337p4ssw0rd!") )
	if err != nil {
		// handle error
	}
	// hashed value: $2id$ihFFCGUfBHTqUfvUIos6X.$AmClxc.3uj6LsxjVGqpOZggyqIL.wQJ9zjY23ztsETK

**`$2id$ihFFCGUfBHTqUfvUIos6X.$AmClxc.3uj6LsxjVGqpOZggyqIL.wQJ9zjY23ztsETK`**    
## Password Hashing (**key'ed hashing** + **masked parameters**)
	p, err := passwd.NewMasked(passwd.Argon2idDefault)
	if err != nil {
		// handle error
	}
	
	// set the hashing key.
	err = p.SetSecret([]byte("myhashingsecret")
	if err != nil {
		// handle error
	}
	
	hashed, err := p.Hash( []byte("my1337p4ssw0rd!") )
	if err != nil {
		// handle error
	}
	// hashed value: $2id$ihFFCGUfBHTqUfvUIos6X.$AmClxc.3uj6LsxjVGqpOZggyqIL.wQJ9zjY23ztsETK

## Password Compare :

## Password Compare (**masked parameters**) :
check a hash against a password, use the profile you defined to compare:  

check a hash against a password:  
	err := p.Compare(hashed, []byte("password"))
	if err != nil {
		// handle error
	}

**`err := p.Compare(hashed, []byte("password"))`**

done.     


Status