| 1 |
package rfc3961 |
| 2 |
|
| 3 |
import ( |
| 4 |
"encoding/hex" |
| 5 |
"testing" |
| 6 |
|
| 7 |
"github.com/stretchr/testify/assert" |
| 8 |
) |
| 9 |
|
| 10 |
func Test_nfold(t *testing.T) { |
| 11 |
t.Parallel() |
| 12 |
var tests = []struct { |
| 13 |
n int |
| 14 |
b []byte |
| 15 |
folded string |
| 16 |
}{ |
| 17 |
{64, []byte("012345"), "be072631276b1955"}, |
| 18 |
{56, []byte("password"), "78a07b6caf85fa"}, |
| 19 |
{64, []byte("Rough Consensus, and Running Code"), "bb6ed30870b7f0e0"}, |
| 20 |
{168, []byte("password"), "59e4a8ca7c0385c3c37b3f6d2000247cb6e6bd5b3e"}, |
| 21 |
{192, []byte("MASSACHVSETTS INSTITVTE OF TECHNOLOGY"), "db3b0d8f0b061e603282b308a50841229ad798fab9540c1b"}, |
| 22 |
{168, []byte("Q"), "518a54a215a8452a518a54a215a8452a518a54a215"}, |
| 23 |
{168, []byte("ba"), "fb25d531ae8974499f52fd92ea9857c4ba24cf297e"}, |
| 24 |
} |
| 25 |
for _, test := range tests { |
| 26 |
assert.Equal(t, test.folded, hex.EncodeToString(Nfold(test.b, test.n)), "Folded not as expected") |
| 27 |
} |
| 28 |
} |