]> gitweb.factorcode.org Git - factor.git/blob - extra/crypto/test/xor.factor
Initial import
[factor.git] / extra / crypto / test / xor.factor
1 USING: crypto errors kernel test strings ;
2
3 ! No key
4 [ T{ no-xor-key f } ] [ [ "" dup xor-crypt ] catch ] unit-test
5 [ T{ no-xor-key f } ] [ [ { } dup xor-crypt ] catch ] unit-test
6 [ T{ no-xor-key f } ] [ [ V{ } dup xor-crypt ] catch ] unit-test
7 [ T{ no-xor-key f } ] [ [ "" "asdf" dupd xor-crypt xor-crypt ] catch ] unit-test
8
9 ! a xor a = 0
10 [ { 0 0 0 0 0 0 0 } ] [ "abcdefg" dup xor-crypt ] unit-test
11
12 [ { 15 15 15 15 } ] [ { 10 10 10 10 } { 5 5 5 5 } xor-crypt ] unit-test
13
14 [ "asdf" ] [ "key" "asdf" dupd xor-crypt xor-crypt >string ] unit-test
15 [ "" ] [ "key" "" xor-crypt >string ] unit-test
16 [ "a longer message...!" ] [
17     "."
18     "a longer message...!" dupd xor-crypt xor-crypt >string
19 ] unit-test
20 [ "a longer message...!" ] [
21     "a very long key, longer than the message even."
22     "a longer message...!" dupd xor-crypt xor-crypt >string
23 ] unit-test