Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 142705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:58:45+00:00 2026-05-11T07:58:45+00:00

I’m trying to compute hmac using sha-512. The Perl code: use Digest::SHA qw(hmac_sha512_hex); $key

  • 0

I’m trying to compute hmac using sha-512.

The Perl code:

use Digest::SHA qw(hmac_sha512_hex);  $key = '\x0b'x20; $data = 'Hi There';  $hash = hmac_sha512_hex($data, $key); print '$hash\n'; 

and gives the correct hash of

87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b30545e17cde   daa833b7d6b8a702038b274eaea3f4e4be9d914eeb61f1702e696c203a126854 

Python version:

import hashlib, hmac  print hmac.new('\x0b'*20, 'Hi There', hashlib.sha512).hexdigest() 

which gives the incorrect hash of

9656975ee5de55e75f2976ecce9a04501060b9dc22a6eda2eaef638966280182 477fe09f080b2bf564649cad42af8607a2bd8d02979df3a980f15e2326a0a22a 

any ideas why the Python version is giving me the wrong hash?

Edit:
version is
Python 2.5.1 (r251:54863, Jan 13 2009, 10:26:13)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T07:58:45+00:00Added an answer on May 11, 2026 at 7:58 am

    yes indeed — it seems the Leopard version of python2.5 is the one that is broken.

    below run on a Penryn-based MBP…

    $ **uname -a** Darwin lizard-wifi 9.6.0 Darwin Kernel Version 9.6.0: Mon Nov 24 17:37:00 PST 2008; root:xnu-1228.9.59~1/RELEASE_I386 i386 dpc@lizard-wifi:~$ **which python** /usr/bin/python 

    Running this version installed in Leopard OS

    dpc@lizard-wifi:~$ python Python 2.5.1 (r251:54863, Jan 13 2009, 10:26:13)  [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type 'help', 'copyright', 'credits' or 'license' for more information. >>> import hashlib, hmac >>> print hmac.new('\x0b'*20, 'Hi There', hashlib.sha512).hexdigest() 9656975ee5de55e75f2976ecce9a04501060b9dc22a6eda2eaef638966280182477fe09f080b2bf564649cad42af8607a2bd8d02979df3a980f15e2326a0a22a >>>  

    And then the MacPorts version of python2.5

    $ /opt/local/bin/python2.5 Python 2.5.4 (r254:67916, Feb  3 2009, 21:40:31)  [GCC 4.0.1 (Apple Inc. build 5488)] on darwin Type 'help', 'copyright', 'credits' or 'license' for more information. >>> import hashlib, hmac >>> print hmac.new('\x0b'*20, 'Hi There', hashlib.sha512).hexdigest() 87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b30545e17cdedaa833b7d6b8a702038b274eaea3f4e4be9d914eeb61f1702e696c203a126854 >>>  
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.