/usr/share/doc/hashcash/examples/hashcash-request is in hashcash 1.21-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | #!/usr/bin/perl
# $Id: hashcash-request,v 1.2 2004/03/31 05:05:10 kyle Exp $
#
# hashcash-request
#
# This goes with hashcash-daemon. Use this script to make a request for
# the daemon to precompute a token for a later message. When the daemon
# isn't busy, it will make the token to be used later.
#
# An up-to-date version is normally here:
# http://www.toehold.com/~kyle/hashcash/
#
# Consider this ALPHA software. It works for me, but it has not been through
# much real testing.
#
# Copyright (C) 2004 Kyle Hasselbacher <kyle@toehold.com>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
use strict;
use Data::Dumper;
#
# I want to support some of the same flags that hashcash does.
#
# -b bits find or check partial hash collision of length bits
# -r resource resource name for minting or checking token
# -e period time until token expires
# -t time modify current time token created at
# -a time modify time by random amount in range given
# -u give time in UTC instead of local time
# -h print this usage info
# -z width width of time field 2,4,6,8,10 or 12 chars (default 6)
# -L limit -- make no more than this many tokens for a given resource
# This hash will be sent to hashcash-sendmail when it's done.
my $add = { 'nice' => 19 };
# Process command line arguments. A better processor would do some
# sanity checks on these.
while ( defined( my $arg = shift ) ) {
if ( $arg eq '-b' ) {
$$add{ 'bits' } = shift;
}
elsif ( $arg eq '-t' ) {
$$add{ 'expiry' } = shift;
}
elsif ( $arg eq '-r' ) {
$$add{ 'addr' } = shift;
}
elsif ( $arg eq '-h' ) {
print<<'END_OF_HELP';
-b bits find partial hash collision of length bits
-r resource resource name for minting token
-t time modify current time token created at
-h print this usage info
END_OF_HELP
exit;
}
}
if ( ! exists( $$add{ 'addr' } ) ) {
$$add{ 'addr' } = undef;
}
my @rcpt = ( $add );
#my $width = 6;
#$width = $opt_z if ( defined( $opt_z ) );
#if ( $width != 2 && $width != 4 && $width != 6 && $width != 8 &&
# $width != 10 && $width != 12 ) {
# die "Acceptible widths are 2, 4, 6, 8, 10 or 12.\n";
#}
# Open a pipe to hashcash-sendmail. Invoking it this way implies that
# a request is on the way in on standard input.
if ( ! open( HCSM, "|hashcash-sendmail" ) ) {
die "Can't execute hashcash-sendmail: $!\n";
}
$Data::Dumper::Useqq = 1;
my $dump = Data::Dumper->Dump( [ \@rcpt ], [ qw( *rcpt ) ] );
$dump .= "\n1;\n";
print HCSM $dump;
close( HCSM );
exit 0;
# $Log: hashcash-request,v $
# Revision 1.2 2004/03/31 05:05:10 kyle
# It does the same thing but completely differently to go with the new
# hashcash-sendmail which doesn't have a hashcash-daemon
#
# Revision 1.1 2004/03/24 17:49:48 kyle
# Initial revision
#
|