Skip to content

Commit

Permalink
💡 argon2: fixes grammar and comment line length.
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewhartstonge committed Nov 5, 2022
1 parent dbcf024 commit 33eee5b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 7 additions & 4 deletions argon2.go
Expand Up @@ -168,7 +168,8 @@ func MemoryConstrainedDefaults() Config {

// Hash takes a password and optionally a salt and returns an Argon2 hash.
//
// If salt is nil a appropriate salt of Config.SaltLength bytes is generated for you.
// If salt is nil an appropriate salt of Config.SaltLength bytes is generated
// for you.
func (c *Config) Hash(pwd []byte, salt []byte) (Raw, error) {
if pwd == nil {
return Raw{}, ErrPwdTooShort
Expand Down Expand Up @@ -214,7 +215,8 @@ func (c *Config) HashEncoded(pwd []byte) (encoded []byte, err error) {
return
}

// Raw wraps a salt and hash pair including the Config with which it was generated.
// Raw wraps a salt and hash pair including the Config with which it was
// generated.
//
// A Raw struct is generated using Decode() or the Hash*() methods above.
//
Expand All @@ -239,7 +241,8 @@ func (raw *Raw) Verify(pwd []byte) (bool, error) {
return subtle.ConstantTimeCompare(r.Hash, raw.Hash) == 1, nil
}

// VerifyEncoded returns true if `pwd` matches the encoded hash `encoded` and otherwise false.
// VerifyEncoded returns true if `pwd` matches the encoded hash `encoded` and
// otherwise false.
func VerifyEncoded(pwd []byte, encoded []byte) (bool, error) {
r, err := Decode(encoded)
if err != nil {
Expand All @@ -249,7 +252,7 @@ func VerifyEncoded(pwd []byte, encoded []byte) (bool, error) {
}

// SecureZeroMemory is a helper method which sets all bytes in `b`
// (up to it's capacity) to `0x00`, erasing it's contents.
// (up to its capacity) to `0x00`, erasing its contents.
func SecureZeroMemory(b []byte) {
b = b[:cap(b):cap(b)]
for i := range b {
Expand Down
6 changes: 4 additions & 2 deletions encoding.go
Expand Up @@ -175,7 +175,8 @@ var (
encTypID = []byte("id$v=")
)

// Encode turns a Raw struct into the official stringified/encoded argon2 representation.
// Encode turns a Raw struct into the official stringified/encoded argon2
// representation.
//
// The resulting byte slice can safely be turned into a string.
func (raw *Raw) Encode() []byte {
Expand Down Expand Up @@ -220,7 +221,8 @@ func (raw *Raw) Encode() []byte {
return buf
}

// Decode takes a stringified/encoded argon2 hash and turns it back into a Raw struct.
// Decode takes a stringified/encoded argon2 hash and turns it back into a Raw
// struct.
//
// This decoder ignores "data" attributes as they are likely to be deprecated.
func Decode(encoded []byte) (Raw, error) {
Expand Down

0 comments on commit 33eee5b

Please sign in to comment.