factor/extra/crypto/xor/xor.factor

13 lines
345 B
Factor
Raw Normal View History

2008-10-02 19:45:51 -04:00
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel math sequences fry ;
2007-10-07 00:01:26 -04:00
IN: crypto.xor
2008-10-02 19:45:51 -04:00
: mod-nth ( n seq -- elt ) [ length mod ] [ nth ] bi ;
2007-10-07 00:01:26 -04:00
2008-10-02 19:45:51 -04:00
ERROR: empty-xor-key ;
: xor-crypt ( seq key -- seq' )
2008-12-07 00:01:17 -05:00
[ empty-xor-key ] when-empty
2009-10-06 21:29:43 -04:00
[ dup length iota ] dip '[ _ mod-nth bitxor ] 2map ;