github.com/blend/go-sdk@v1.20240719.1/crypto/create_key_test.go (about) 1 /* 2 3 Copyright (c) 2024 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package crypto 9 10 import ( 11 "crypto/hmac" 12 "testing" 13 14 "github.com/blend/go-sdk/assert" 15 ) 16 17 func Test_CreateKey(t *testing.T) { 18 t.Parallel() 19 20 its := assert.New(t) 21 22 key, err := CreateKey(32) 23 its.Nil(err) 24 its.Len(key, 32) 25 26 key2, err := CreateKey(32) 27 its.Nil(err) 28 its.Len(key2, 32) 29 30 its.False(hmac.Equal(key, key2)) 31 } 32 33 func Test_CreateIntKey(t *testing.T) { 34 t.Parallel() 35 36 its := assert.New(t) 37 38 key, err := CreateIntKey(6) 39 its.Nil(err) 40 its.Len(key, 6) 41 } 42 43 func Test_CreateIntKeyError(t *testing.T) { 44 t.Parallel() 45 46 its := assert.New(t) 47 48 key, err := CreateIntKey(0) 49 its.NotNil(err) 50 its.Empty(key) 51 }