in reply to Would Like Recommendation for an SHA256 module

You missed Digest::SHA. If the modules are otherwise equal, you should probably use Digest::SHA since people will be able to use the slower Digest::SHA::PurePerl as a drop-in replacement if they have problems installing Digest::SHA. Also, Digest::SHA's functional interface provides simple and easy access to common tasks.

By the way, while the [cpan://] is useful for searching, [mod://] is much better when linking to a specific module. e.g. [cpan://Digest::SHA] vs [mod://Digest::SHA]

Replies are listed 'Best First'.
Re^2: Would Like Recommendation for an SHA256 module
by bart (Canon) on Aug 01, 2006 at 06:55 UTC
    Digest::SHA's functional interface provides simple and easy access to common tasks.
    Don't do it that way. Instead, use Digest as a base module, and you can use any compatible Digest::* module as a plug-in. That way, your code doesn't have to change when switching between hash implementations — only the specification of what hash to use (a string), in the call to new.

    See also the speed comparison table in that same module.

      use Digest as a base module

      I'm a novice when it comes to modules, so I'm not sure what you mean. Are you suggesting something different than just putting use Digest::SHA or use Digest::SHA::PurePerl at the top of my script? They both say they use the same interface as Digest::

      TheEnigma

        Install Digest and Digest::SHA. Don't use Digest::SHA directly. Use the following code instead:

        use Digest (); my $data = ...; my $hasher = Digest->new('SHA-256'); $hasher->add($data); $hasher->b64digest(); # or ->digest or ->hexdigest
Re^2: Would Like Recommendation for an SHA256 module
by TheEnigma (Pilgrim) on Aug 01, 2006 at 04:32 UTC

    I don't think I can use Digest::SHA, since this is hosted on a 3rd party hosting service, and I wouldn't be able to recompile it. But, you're right, Digest::SHA would be better if I can use it, and if Mark Shelor's program turns out to be the module of choice.

    Thanks for the tip about the link! I was being lazy and going on memory for what to use, I should have looked it up.

    TheEnigma

      If you can't compile the module, then that only leaves you with (the slow) Digest::SHA::PurePerl. The three others are all written in C.
        Practically speaking, it shouldn't matter, there will be less than a dozen users of this script. My main concern is the quality of the module I pick (does it implement the algorithm properly).

        TheEnigma