On 11 Jan 2004 at 11:46, Autrijus Tang wrote: > > Well, there is a pure-perl SHA1 here: > http://search.cpan.org/src/JMASON/Mail-SpamAssassin-2.61/lib/Mail/SpamAssassin/SHA1.pm >
Here is my stab at using the Perl code from the above link. It works, but it involves a little kludge. There is a smaller chicken/egg problem with that code, because it needs: use bytes; use integer; before it can extract bytes.pm and integer.pm. Looking at those modules, in Perl 5.6.1, I see that all they do is tweak bits in $^H which is locally scoped. So I stuck a BEGIN block in the SHA1 sub with bit values copied from the .pm files, instead of the "use" statements. The specific values may not be portable over many Perl versions and might require checking the version to set the right bits. It might be possible to re-write the SHA code so it does integer math without "use integer", but it is already not real fast and I can't really understand what it's doing that well. Hacking $^H was much easier :) Of course, all this only affects standalone scripts from "pp -P", not binaries with fast C code SHA1. If you assume that there is a local Perl installation being used to run the standalone script, it might be reasonable to assume that the Perl installation has Digest::SHA1 and go with the first changes to par.pl and Par.pm that I did. As noted in the SpamAssassin code, Digest::SHA1 is a lot faster than the pure Perl code. It's your choice... Attached is the modified (again) parl.pl and Par.pm. Alan Stewart P.S. If you "set PAR_CLEAN=1" and then run: pp -o tt.exe t.pl the temp dir from the pp run is deleted, but if you run: pp -P -o tt.pl t.pl a temp dir from the pp run is empty, but still there and is a "temp-$pid" type. I haven't looked for the cause of this.
The following section of this message contains a file attachment
prepared for transmission using the Internet MIME message format.
If you are using Pegasus Mail, or any another MIME-compliant system,
you should be able to save it or view it from within your mailer.
If you cannot, please ask your system administrator for assistance.
---- File information -----------
File: par_mod2.zip
Date: 11 Jan 2004, 1:05
Size: 15431 bytes.
Type: ZIP-archive
par_mod2.zip
Description: Zip archive
