Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
supercaracal committed Jun 26, 2021
1 parent 18c0e64 commit bb1d831
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const (
func genSalt(size int) ([]byte, error) {
salt := make([]byte, size)
if _, err := io.ReadFull(rand.Reader, salt); err != nil {
return nil, nil
return nil, err
}
return salt, nil
}
Expand All @@ -42,7 +42,7 @@ func readRawPassword(fd int) ([]byte, error) {
return input, nil
}

func encryptPassword(rawPassword, salt []byte, iter, keyLen int) (string, error) {
func encryptPassword(rawPassword, salt []byte, iter, keyLen int) string {
digestKey := pbkdf2.Key(rawPassword, salt, iter, keyLen, sha256.New)
h := hmac.New(sha256.New, digestKey)

Expand All @@ -62,7 +62,7 @@ func encryptPassword(rawPassword, salt []byte, iter, keyLen int) (string, error)
string(b64Salt),
string(b64ClientKey),
string(b64ServerKey),
), nil
)
}

func main() {
Expand All @@ -83,12 +83,6 @@ func main() {
os.Exit(1)
}

output, err := encryptPassword(rawPassword, salt, iterationCnt, digestLen)
if err != nil {
fmt.Println(err)
os.Exit(1)
}

fmt.Printf("\n%s\n", output)
fmt.Printf("\n%s\n", encryptPassword(rawPassword, salt, iterationCnt, digestLen))
os.Exit(0)
}

0 comments on commit bb1d831

Please sign in to comment.