package cryptography import ( "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestBcryptHashAndVerify(t *testing.T) { input := "super-secret-password" hash, err := BcryptHash(input) require.NoError(t, err) require.NotEmpty(t, hash) assert.NotEqual(t, input, hash) assert.True(t, BcryptVerify(input, hash)) } func TestBcryptVerifyWrongPassword(t *testing.T) { hash, err := BcryptHash("correct-password") require.NoError(t, err) assert.False(t, BcryptVerify("wrong-password", hash)) } func TestBcryptHashUniqueness(t *testing.T) { h1, _ := BcryptHash("same") h2, _ := BcryptHash("same") // bcrypt uses a random salt – hashes must differ assert.NotEqual(t, h1, h2) } func TestBcryptHashEmptyInput(t *testing.T) { hash, err := BcryptHash("") require.NoError(t, err) assert.True(t, BcryptVerify("", hash)) }