]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/crypto/passwd-md5/passwd-md5.factor
factor: trim using lists
[factor.git] / extra / crypto / passwd-md5 / passwd-md5.factor
index a8706a75316ee9f1f95830107a252f55f707dad5..3d5b53aa841a2501d2899a3d51cd0e37034f2e7b 100644 (file)
@@ -1,8 +1,7 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel base64 checksums.md5 sequences checksums
-locals prettyprint math math.bits grouping io combinators
-fry make combinators.short-circuit math.functions splitting ;
+USING: checksums checksums.md5 combinators grouping kernel math
+math.bits math.functions sequences splitting ;
 IN: crypto.passwd-md5
 
 <PRIVATE
@@ -18,7 +17,7 @@ PRIVATE>
 
 :: passwd-md5 ( magic salt password -- bytes )
     password magic salt 3append
-    salt password dup surround md5 checksum-bytes
+    salt password 1surround md5 checksum-bytes
     password length
     [ 16 / ceiling swap <repetition> concat ] keep
     head-slice append
@@ -26,7 +25,7 @@ PRIVATE>
     '[ CHAR: \0 _ ? ] "" map-as append
     md5 checksum-bytes :> final!
 
-    1000 iota [
+    1000 <iota> [
         "" swap
         {
             [ 0 bit? password final ? append ]
@@ -40,9 +39,9 @@ PRIVATE>
     { 12 0 6 13 1 7 14 2 8 15 3 9 5 4 10 } final nths 3 group
     [ first3 [ 16 shift ] [ 8 shift ] bi* + + 4 to64 ] map concat
     11 final nth 2 to64 3append ;
-        
+
 : parse-shadow-password ( string -- magic salt password )
-    "$" split harvest first3 [ "$" dup surround ] 2dip ;
-    
+    "$" split harvest first3 [ "$" 1surround ] 2dip ;
+
 : authenticate-password ( shadow password -- ? )
     '[ parse-shadow-password drop _ passwd-md5 ] keep = ;