]> gitweb.factorcode.org Git - factor.git/commitdiff
fix contrib/crypto
authorerg <erg@trifocus.net>
Sat, 14 Oct 2006 06:26:34 +0000 (06:26 +0000)
committererg <erg@trifocus.net>
Sat, 14 Oct 2006 06:26:34 +0000 (06:26 +0000)
contrib/crypto/base64.factor
contrib/math/utils.factor

index 01a7516112b580fb511161856c1b6732cb7b57dc..ad6700c6435e6a5a419005fcf88116a5ff8a87bc 100644 (file)
@@ -1,7 +1,6 @@
 USING: kernel math math-contrib sequences namespaces io strings hashtables ;
 IN: crypto-internals
 
-
 : ch>base64 ( ch -- ch )
     "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" nth ;
 
@@ -36,6 +35,6 @@ IN: crypto
 : base64> ( str -- str )
     #! input length must be a mulitple of 4
     [
-        [ 4 group [ decode4 % ] each ] keep CHAR: = swap count-end
+        [ 4 group [ decode4 % ] each ] keep [ CHAR: = = not ] count-end 
     ] SBUF" " make swap [ dup pop* ] times >string ;
 
index 0d766275015da234c7810b869c2b9268859c56cc..947b73e16a7a5f6a16296de6d7afee928a6ed21f 100644 (file)
@@ -101,3 +101,6 @@ SYMBOL: step-size .01 step-size set  ! base on arguments
 
 : nth-rand ( seq -- elem ) [ length random-int ] keep nth ;
 
+: count-end ( seq quot -- count )
+    >r [ length ] keep r> find-last drop dup -1 = [ 2drop 0 ] [ - 1- ] if ;
+