goext/cryptext/hash_test.go

21 lines
1.1 KiB
Go
Raw Permalink Normal View History

2022-10-27 16:00:57 +02:00
package cryptext
import (
2023-03-31 13:33:06 +02:00
"gogs.mikescher.com/BlackForestBytes/goext/tst"
2022-10-27 16:00:57 +02:00
"testing"
)
func TestStrSha256(t *testing.T) {
2023-03-31 13:33:06 +02:00
tst.AssertEqual(t, StrSha256(""), "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
tst.AssertEqual(t, StrSha256("0"), "5feceb66ffc86f38d952786c6d696c79c2dbc239dd4e91b46729d73a27fb57e9")
tst.AssertEqual(t, StrSha256("80085"), "b3786e141d65638ad8a98173e26b5f6a53c927737b23ff31fb1843937250f44b")
tst.AssertEqual(t, StrSha256("Hello World"), "a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e")
2022-10-27 16:00:57 +02:00
}
func TestBytesSha256(t *testing.T) {
2023-03-31 13:33:06 +02:00
tst.AssertEqual(t, BytesSha256([]byte{}), "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
tst.AssertEqual(t, BytesSha256([]byte{0}), "6e340b9cffb37a989ca544e6bb780a2c78901d3fb33738768511a30617afa01d")
tst.AssertEqual(t, BytesSha256([]byte{128}), "76be8b528d0075f7aae98d6fa57a6d3c83ae480a8469e668d7b0af968995ac71")
tst.AssertEqual(t, BytesSha256([]byte{0, 1, 2, 4, 8, 16, 32, 64, 128, 255}), "55016a318ba538e00123c736b2a8b6db368d00e7e25727547655b653e5853603")
2023-02-03 00:59:54 +01:00
}