[OT] Combinatronics WAS Re: /dev/random and linux security
issues (kinda long)
Kevin D. Clark
clark_k at pannaway.com
Tue May 17 08:23:01 EDT 2005
I sent these to Dave yesterday but I haven't heard any feedback yet.
I've done a small amount of testing with these and they seem to work
just fine. If you find a bug in these, please let me know.
This code uses "bigint" because, after all, we're dealing with
integers.
--kevin
--
GnuPG ID: B280F24E And the madness of the crowd
alumni.unh.edu!kdc Is an epileptic fit
-- Tom Waits
-------------- next part --------------
#!/usr/bin/perl
# read a decimal integer from STDIN and return its value, in base 95, on stdout
# this uses the printable ASCII characters, in order, as the digits of base 95
# input and output are both MSDF
use bigint;
$line = <>;
$line =~ /^([0-9]+)/;
$dec = $1 +0;
$epsilon = 1;
$base = 95;
while ($dec > $epsilon) {
$digit = $dec % $base;
$newdec = $dec / $base;
$dec = $newdec;
$result = chr($digit + 32) . "$result";
}
print "$result\n";
-------------- next part --------------
#!/usr/bin/perl
# read a decimal integer from STDIN and return its value, in base 95, on stdout
# this uses the printable ASCII characters, in order, as the digits of base 95
# input and output are both MSDF
use bigint;
$b95 = <>; chomp($b95);
map { $dec *= 95; $dec += (ord($_) - 32); } split(//, $b95);
print $dec, "\n";
exit;
More information about the gnhlug-discuss
mailing list