Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Digest::HMAC

Reply
Thread Tools

Digest::HMAC

 
 
rihad
Guest
Posts: n/a
 
      11-05-2009
Hi there, I need to convert this PHP code to Perl. How?

hash_hmac('sha1','Data to be hashed', 'some_secret_key');

I've looked into Digest::HMAC, but there's no way to specify sha1.
There's also Digest::SHA1, but I don't know how to mix the two
together.

Please help.
 
Reply With Quote
 
 
 
 
C.DeRykus
Guest
Posts: n/a
 
      11-05-2009
On Nov 5, 7:26*am, rihad <(E-Mail Removed)> wrote:
> Hi there, I need to convert this PHP code to Perl. How?
>
> hash_hmac('sha1','Data to be hashed', 'some_secret_key');
>
> I've looked into Digest::HMAC, but there's no way to specify sha1.
> There's also Digest::SHA1, but I don't know how to mix the two
> together.



See: Digest::HMAC_SHA1

http://search.cpan.org/~gaas/Digest-...t/HMAC_SHA1.pm

--
Charles DeRykus
 
Reply With Quote
 
 
 
 
rihad
Guest
Posts: n/a
 
      11-05-2009
C.DeRykus wrote:
> See: Digest::HMAC_SHA1
>
> http://search.cpan.org/~gaas/Digest-...t/HMAC_SHA1.pm
>

Hm, thanks. It's so strange I couldn't find it in FreeBSD ports.
 
Reply With Quote
 
rihad
Guest
Posts: n/a
 
      11-05-2009
> Hm, thanks. It's so strange I couldn't find it in FreeBSD ports.
Oh, I see. This is how I'd do it:

use Digest::SHA1 qw(sha1);
use Digest::HMAC qw(hmac);

hmac('some_data', 'some_key', \&sha1, 64);

So Digest::HMAC_SHA1 simply show how to interconnect the two, just
what I needed.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments