in reply to Re: Would Like Recommendation for an SHA256 module
in thread Would Like Recommendation for an SHA256 module

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.

Replies are listed 'Best First'.
Re^3: Would Like Recommendation for an SHA256 module
by TheEnigma (Pilgrim) on Aug 01, 2006 at 21:41 UTC

    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