Home / Function/ Test_parseHashedPassword() — fiber Function Reference

Test_parseHashedPassword() — fiber Function Reference

Architecture documentation for the Test_parseHashedPassword() function in basicauth_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  eccc3360_6ccc_cef3_834c_e8334f277553["Test_parseHashedPassword()"]
  c1fa52c0_acd4_56de_8c46_542417f3c9b8["basicauth_test.go"]
  eccc3360_6ccc_cef3_834c_e8334f277553 -->|defined in| c1fa52c0_acd4_56de_8c46_542417f3c9b8
  824a33e0_c7e5_0667_eed0_344e2a530f7a["sha512Hash()"]
  eccc3360_6ccc_cef3_834c_e8334f277553 -->|calls| 824a33e0_c7e5_0667_eed0_344e2a530f7a
  bfd8a9b6_0e17_60de_7e62_37b7a2f1750e["sha256Hash()"]
  eccc3360_6ccc_cef3_834c_e8334f277553 -->|calls| bfd8a9b6_0e17_60de_7e62_37b7a2f1750e
  style eccc3360_6ccc_cef3_834c_e8334f277553 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

middleware/basicauth/basicauth_test.go lines 516–545

func Test_parseHashedPassword(t *testing.T) {
	t.Parallel()
	pass := "secret"
	sha := sha256.Sum256([]byte(pass))
	b64 := base64.StdEncoding.EncodeToString(sha[:])
	hexDigest := hex.EncodeToString(sha[:])
	bcryptHash, err := bcrypt.GenerateFromPassword([]byte(pass), bcrypt.MinCost)
	require.NoError(t, err)

	cases := []struct {
		name   string
		hashed string
	}{
		{"bcrypt", string(bcryptHash)},
		{"sha512", sha512Hash(pass)},
		{"sha256", sha256Hash(pass)},
		{"sha256-hex", hexDigest},
		{"sha256-b64", b64},
	}

	for _, tt := range cases {
		t.Run(tt.name, func(t *testing.T) {
			t.Parallel()
			verify, err := parseHashedPassword(tt.hashed)
			require.NoError(t, err)
			require.True(t, verify(pass))
			require.False(t, verify("wrong"))
		})
	}
}

Domain

Subdomains

Frequently Asked Questions

What does Test_parseHashedPassword() do?
Test_parseHashedPassword() is a function in the fiber codebase, defined in middleware/basicauth/basicauth_test.go.
Where is Test_parseHashedPassword() defined?
Test_parseHashedPassword() is defined in middleware/basicauth/basicauth_test.go at line 516.
What does Test_parseHashedPassword() call?
Test_parseHashedPassword() calls 2 function(s): sha256Hash, sha512Hash.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free