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

26 lines
960 B
Factor
Raw Normal View History

2007-10-07 00:01:26 -04:00
USING: continuations crypto.xor kernel strings tools.test ;
2008-03-01 17:00:45 -05:00
IN: crypto.xor.tests
2007-09-20 18:09:08 -04:00
! No key
2008-10-02 19:45:51 -04:00
[ "" dup xor-crypt ] [ T{ empty-xor-key } = ] must-fail-with
[ { } dup xor-crypt ] [ T{ empty-xor-key } = ] must-fail-with
[ V{ } dup xor-crypt ] [ T{ empty-xor-key } = ] must-fail-with
[ "" "asdf" dupd xor-crypt xor-crypt ] [ T{ empty-xor-key } = ] 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
2008-10-02 19:45:51 -04:00
[ "asdf" ] [ "asdf" "key" [ xor-crypt ] [ xor-crypt ] bi >string ] unit-test
[ "" ] [ "" "key" xor-crypt >string ] unit-test
2007-09-20 18:09:08 -04:00
[ "a longer message...!" ] [
2008-10-02 19:45:51 -04:00
"a longer message...!"
"." [ xor-crypt ] [ xor-crypt ] bi >string
2007-09-20 18:09:08 -04:00
] unit-test
[ "a longer message...!" ] [
2008-10-02 19:45:51 -04:00
"a longer message...!"
2007-09-20 18:09:08 -04:00
"a very long key, longer than the message even."
2008-10-02 19:45:51 -04:00
[ xor-crypt ] [ xor-crypt ] bi >string
2007-09-20 18:09:08 -04:00
] unit-test