factor/extra/crypto/xor/xor-tests.factor

25 lines
926 B
Factor
Raw Normal View History

2007-10-07 00:01:26 -04:00
USING: continuations crypto.xor kernel strings tools.test ;
IN: temporary
2007-09-20 18:09:08 -04:00
! No key
[ "" dup xor-crypt ] [ T{ no-xor-key f } = ] must-fail-with
[ { } dup xor-crypt ] [ T{ no-xor-key f } = ] must-fail-with
[ V{ } dup xor-crypt ] [ T{ no-xor-key f } = ] must-fail-with
[ "" "asdf" dupd xor-crypt xor-crypt ] [ T{ no-xor-key f } = ] must-fail-with
2007-09-20 18:09:08 -04:00
! a xor a = 0
2007-10-07 00:01:26 -04:00
[ "\0\0\0\0\0\0\0" ] [ "abcdefg" dup xor-crypt ] unit-test
2007-09-20 18:09:08 -04:00
[ { 15 15 15 15 } ] [ { 10 10 10 10 } { 5 5 5 5 } xor-crypt ] unit-test
[ "asdf" ] [ "key" "asdf" dupd xor-crypt xor-crypt >string ] unit-test
[ "" ] [ "key" "" xor-crypt >string ] unit-test
[ "a longer message...!" ] [
"."
"a longer message...!" dupd xor-crypt xor-crypt >string
] unit-test
[ "a longer message...!" ] [
"a very long key, longer than the message even."
"a longer message...!" dupd xor-crypt xor-crypt >string
] unit-test