add sha2 test file

darcs
erg 2006-09-12 02:36:13 +00:00
parent 4720e8a4a5
commit 221c464a7e
2 changed files with 8 additions and 1 deletions

View File

@ -120,6 +120,7 @@ SYMBOL: >word
: string>sha2 ( string -- string )
t preprocess-plaintext
block-size get group [ process-chunk ] each
4 H get seq>string ;
IN: sha2
: string>sha-256 ( string -- string )
@ -130,7 +131,6 @@ IN: sha2
64 block-size set
\ >32-bit >word set
string>sha2
4 H get seq>string
] with-scope ;
: string>sha-256-string ( string -- hexstring )

View File

@ -0,0 +1,7 @@
USING: kernel math test namespaces crypto sha2 ;
[ "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" ] [ "" string>sha-256-string ] unit-test
[ "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" ] [ "abc" string>sha-256-string ] unit-test
[ "f7846f55cf23e14eebeab5b4e1550cad5b509e3348fbc4efa3a1413d393cb650" ] [ "message digest" string>sha-256-string ] unit-test
[ "71c480df93d6ae2f1efad1447c66c9525e316218cf51fc8d9ed832f2daf18b73" ] [ "abcdefghijklmnopqrstuvwxyz" string>sha-256-string ] unit-test
[ "db4bfcbd4da0cd85a60c3c37d3fbd8805c77f15fc6b1fdfe614ee0a7c8fdb4c0" ] [ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" string>sha-256-string ] unit-test
[ "f371bc4a311f2b009eef952dd83ca80e2b60026c8e935592d0f9c308453c813e" ] [ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" string>sha-256-string ] unit-test