-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eab83b7
commit 9ed48d5
Showing
5 changed files
with
40 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package veriff | ||
|
||
import ( | ||
"crypto/hmac" | ||
"crypto/sha256" | ||
"fmt" | ||
) | ||
|
||
func SignPayload(secret, payload string) string { | ||
digest := hmac.New(sha256.New, []byte(secret)) | ||
digest.Write([]byte(payload)) | ||
return fmt.Sprintf("%x", digest.Sum(nil)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package veriff_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/brokeyourbike/veriff-api-client-go" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestSignPayload(t *testing.T) { | ||
signed1 := veriff.SignPayload("secret", "") | ||
signed2 := veriff.SignPayload("secret", string([]byte{})) | ||
|
||
assert.Equal(t, signed1, signed2) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters