Digest::HMAC

Discussion in 'Perl Misc' started by rihad, Nov 5, 2009.

  1. rihad

    rihad Guest

    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.
    rihad, Nov 5, 2009
    #1
    1. Advertising

  2. rihad

    C.DeRykus Guest

    On Nov 5, 7:26 am, rihad <> 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-HMAC-1.01/lib/Digest/HMAC_SHA1.pm

    --
    Charles DeRykus
    C.DeRykus, Nov 5, 2009
    #2
    1. Advertising

  3. rihad

    rihad Guest

    rihad, Nov 5, 2009
    #3
  4. rihad

    rihad Guest

    > 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.
    rihad, Nov 5, 2009
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ed

    portable sha1 hmac sources

    ed, Apr 6, 2006, in forum: C Programming
    Replies:
    2
    Views:
    351
    William Ahern
    Apr 8, 2006
  2. Replies:
    4
    Views:
    5,824
    Thomas J. Gritzan
    Sep 22, 2006
  3. Tammy Mc
    Replies:
    3
    Views:
    212
    Tammy Mc
    Oct 1, 2006
  4. myalo
    Replies:
    4
    Views:
    1,289
    A. Sinan Unur
    Nov 28, 2007
  5. Replies:
    2
    Views:
    329
    Julian Cromarty
    Jun 26, 2013
Loading...

Share This Page