in reply to Alternative Perl encryption module
This is not an answer, sorry. I searched CPAN and found many modules dealing with Digest; the most common ones (MD2, MD4, MD5, SHA-1) produce strings longer than 20 bytes... Here is the code I used to test it:
#!/usr/bin/perl use strict; use Digest; my $data = "message to be digested"; for ('MD2', 'MD4', 'MD5', 'SHA-1') { showme($_, Digest->new($_), $data); } exit; sub showme { my ($mode, $digest, $data) = @_; $digest->add($data); print "Digest::$mode\n"; print "binary (length): ", length($digest->digest), "\n"; print "hex : ", $digest->hexdigest, "\n"; if ($digest->can('b64digest')) { print "base64 : ", $digest->b64digest, "\n"; } print "\n"; } __END__ # output Digest::MD2 binary (length): 16 hex : 8350e5a3e24c153df2275c9f80692773 base64 : g1Dlo+JMFT3yJ1yfgGkncw Digest::MD4 binary (length): 16 hex : 0962f09cec91822209796b504862847b Digest::MD5 binary (length): 16 hex : d41d8cd98f00b204e9800998ecf8427e base64 : 1B2M2Y8AsgTpgAmY7PhCfg Digest::SHA-1 binary (length): 20 hex : da39a3ee5e6b4b0d3255bfef95601890afd80709 base64 : 2jmj7l5rSw0yVb/vlWAYkK/YBwk
Given these digest methods, only binary format seems suitable for your needs... does anybody know of other algorithms?
Ciao, Valerio
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Alternative Perl encryption module
by mowgli (Friar) on Mar 10, 2003 at 13:02 UTC | |
by hardburn (Abbot) on Mar 10, 2003 at 15:05 UTC | |
by mowgli (Friar) on Mar 10, 2003 at 17:35 UTC |