-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added an interface and default hashser
- Loading branch information
Richard Bowden
committed
Dec 17, 2017
1 parent
783531d
commit 261590c
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package passwordHash | ||
|
||
import "github.com/richardbowden/passwordHash" | ||
|
||
// PasswordHasher is an interface that describes two basic functions that can be | ||
// used to perform a password encode and validate | ||
type PasswordHasher interface { | ||
Encode(pw1 string, pw2 string) (string, error) | ||
Validate(pw string, hashPackage string) (bool, error) | ||
} | ||
|
||
// DefaultPasswordHasher impliments the PasswordHasher interface which uses passwordHash | ||
type DefaultPasswordHasher struct{} | ||
|
||
func (DefaultPasswordHasher) Encode(pw1 string, pw2 string) (string, error) { | ||
return passwordHash.HashWithDefaults(pw1, pw2) | ||
} | ||
|
||
func (DefaultPasswordHasher) Validate(pw string, hashedPackage string) (bool, error) { | ||
return passwordHash.Validate(pw, hashedPackage) | ||
} |