Skip to content

Commit

Permalink
Merge pull request #2 from richardbowden/develop
Browse files Browse the repository at this point in the history
adds a passwordHasher interface and default implementation
  • Loading branch information
richardbowden authored Dec 17, 2017
2 parents 1eee3c2 + 5c39fc7 commit efc6686
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ _testmain.go
*.exe
*.test
*.prof
debug
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions passwordHasher.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package 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 HashWithDefaults(pw1, pw2)
}

func (DefaultPasswordHasher) Validate(pw string, hashedPackage string) (bool, error) {
return Validate(pw, hashedPackage)
}

0 comments on commit efc6686

Please sign in to comment.