From c13ccf2dfedc2a79fd5fd90ef16801a4125f07ed Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Tue, 16 Mar 2021 08:13:21 -0700 Subject: [PATCH] hashcash: change available-chars to a constant. --- extra/hashcash/hashcash.factor | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/extra/hashcash/hashcash.factor b/extra/hashcash/hashcash.factor index 0342655172..b0f7efc274 100644 --- a/extra/hashcash/hashcash.factor +++ b/extra/hashcash/hashcash.factor @@ -1,9 +1,9 @@ ! Copyright (C) 2009 Diego Martinelli. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors calendar checksums checksums.openssl classes.tuple -formatting fry io.encodings.ascii io.encodings.string kernel math -math.functions math.parser math.ranges present random sequences -splitting ; +USING: accessors byte-arrays calendar checksums +checksums.openssl classes.tuple formatting io.encodings.ascii +io.encodings.string kernel literals math math.functions +math.parser math.ranges present random sequences splitting ; IN: hashcash ! Hashcash implementation @@ -24,14 +24,15 @@ IN: hashcash ! Random salt is formed by ascii characters ! between 33 and 126 -: available-chars ( -- seq ) - 33 126 [a,b] [ CHAR: : = ] reject ; +CONSTANT: available-chars $[ + CHAR: : 33 126 [a,b] remove >byte-array +] PRIVATE> ! Generate a 'length' long random salt : salt ( length -- salted ) - available-chars '[ _ random ] "" replicate-as ; + [ available-chars random ] "" replicate-as ; TUPLE: hashcash version bits date resource ext salt suffix ; -- 2.34.1