From 6571d6fc516c901e48f9a2c86c13ff82ff6fad4e Mon Sep 17 00:00:00 2001 From: erg Date: Sun, 12 Nov 2006 19:35:24 +0000 Subject: [PATCH] move base64 to contrib/base64 --- contrib/README.txt | 1 + contrib/{crypto => base64}/base64.factor | 9 ++++++--- contrib/base64/load.factor | 7 +++++++ .../{crypto/test/base64.factor => base64/test.factor} | 6 +++--- contrib/crypto/load.factor | 2 -- 5 files changed, 17 insertions(+), 8 deletions(-) rename contrib/{crypto => base64}/base64.factor (85%) create mode 100644 contrib/base64/load.factor rename contrib/{crypto/test/base64.factor => base64/test.factor} (76%) diff --git a/contrib/README.txt b/contrib/README.txt index d0a0aebef7..c6a4c762c8 100644 --- a/contrib/README.txt +++ b/contrib/README.txt @@ -9,6 +9,7 @@ Available libraries: - alien -- Alien utility words (Eduardo Cavazos) - automata -- Graphics demo for the UI (Eduardo Cavazos) +- base64 -- base64 encoding/decoding (Doug Coleman) - benchmarks -- Various performance benchmarks (Slava Pestov) - boids -- Graphics demo for the UI (Eduardo Cavazos) - cairo -- cairo bindings (Sampo Vuori) diff --git a/contrib/crypto/base64.factor b/contrib/base64/base64.factor similarity index 85% rename from contrib/crypto/base64.factor rename to contrib/base64/base64.factor index ad6700c643..a4d4f09f89 100644 --- a/contrib/crypto/base64.factor +++ b/contrib/base64/base64.factor @@ -1,5 +1,8 @@ -USING: kernel math math-contrib sequences namespaces io strings hashtables ; -IN: crypto-internals +USING: kernel math sequences namespaces io strings hashtables ; +IN: base64-internals + +: count-end ( seq quot -- count ) + >r [ length ] keep r> find-last drop dup -1 = [ 2drop 0 ] [ - 1- ] if ; : ch>base64 ( ch -- ch ) "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" nth ; @@ -22,7 +25,7 @@ IN: crypto-internals : >base64-rem ( str -- str ) [ 3 0 pad-right encode3 ] keep length 1+ head 4 CHAR: = pad-right ; -IN: crypto +IN: base64 : >base64 ( str -- str ) #! cut string into two pieces, convert 3 bytes at a time #! pad string with = when not enough bits diff --git a/contrib/base64/load.factor b/contrib/base64/load.factor new file mode 100644 index 0000000000..70de2d8eca --- /dev/null +++ b/contrib/base64/load.factor @@ -0,0 +1,7 @@ +PROVIDE: contrib/base64 +{ +files+ { + "base64.factor" +} } +{ +tests+ { + "test.factor" +} } ; diff --git a/contrib/crypto/test/base64.factor b/contrib/base64/test.factor similarity index 76% rename from contrib/crypto/test/base64.factor rename to contrib/base64/test.factor index eedbaea217..9bb1780a39 100644 --- a/contrib/crypto/test/base64.factor +++ b/contrib/base64/test.factor @@ -1,8 +1,8 @@ -USING: kernel math test namespaces crypto ; +USING: test base64 ; -[ "abcdefghijklmnopqrstuvwxyz" ] [ "abcdefghijklmnopqrstuvwxyz" >base64 base64> ] unit-test +[ "abcdefghijklmnopqrstuvwxyz" ] [ "abcdefghijklmnopqrstuvwxyz" >base64 base64> +] unit-test [ "" ] [ "" >base64 base64> ] unit-test [ "a" ] [ "a" >base64 base64> ] unit-test [ "ab" ] [ "ab" >base64 base64> ] unit-test [ "abc" ] [ "abc" >base64 base64> ] unit-test - diff --git a/contrib/crypto/load.factor b/contrib/crypto/load.factor index ad8047f854..7ec605a856 100644 --- a/contrib/crypto/load.factor +++ b/contrib/crypto/load.factor @@ -5,7 +5,6 @@ PROVIDE: contrib/crypto "common.factor" "timing.factor" - "base64.factor" "barrett.factor" "montgomery.factor" "random.factor" @@ -32,7 +31,6 @@ PROVIDE: contrib/crypto "test/md5.factor" "test/sha1.factor" "test/sha2.factor" - "test/base64.factor" "test/miller-rabin.factor" "test/crc32.factor" "test/rsa.factor"