keyDerivation_test.go 425 B

1234567891011121314151617181920212223
  1. package rfc4757
  2. import (
  3. "encoding/hex"
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. )
  7. const (
  8. testPassword = "foo"
  9. testKey = "ac8e657f83df82beea5d43bdaf7800cc"
  10. )
  11. func TestStringToKey(t *testing.T) {
  12. t.Parallel()
  13. kb, err := StringToKey(testPassword)
  14. if err != nil {
  15. t.Fatalf("Error deriving key from string: %v", err)
  16. }
  17. k := hex.EncodeToString(kb)
  18. assert.Equal(t, testKey, k, "Key not as expected")
  19. }