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

  • Home
  • SEARCH
  • 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 3311654
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:54:08+00:00 2026-05-17T21:54:08+00:00

i have a javascript password coder md5 = hex_hmac_md5(secret, password) How can i emulate

  • 0

i have a javascript password coder

md5 = hex_hmac_md5(secret, password)

How can i emulate this in python – ive tried md5 but that is not the same value

i got my md5 javascript code from this website:

Pajs Home

(md5.js)

He states the use is as follows:

In many uses of hashes you end up
wanting to combine a key with some
data. It isn’t so bad to do this by
simple concatenation, but HMAC is
specifically designed for this use.
The usage is:

hash = hex_hmac_md5(“key”, “data”);

The HMAC result is also available
base-64 encoded or as a binary string,
using b64_hmac_* or str_hmac_*.

Some other hash libraries have the
arguments the other way round. If the
JavaScript HMAC doesn’t match the
value your server library generates,
try swapping the order.

I have tried some python like this:

> def md5_test(secret, password):
>     
>     return md5(secret+password).hexdigest()

Can anyone tell me what the code should be in python to get the same value?

Thanks

  • 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. Editorial Team
    Editorial Team
    2026-05-17T21:54:09+00:00Added an answer on May 17, 2026 at 9:54 pm

    That’s what Python’s hmac module is for, don’t use the MD5 function directly.

    # Right
    import hmac
    # Note that hmac.new defaults to using MD5
    hmac.new("password", "message").hexdigest() # 'f37438341e3d22aa11b4b2e838120dcf'
    
    # Wrong
    from hashlib import md5
    md5("message"+"password").hexdigest() # 'd0647ee3be62a57c9475541c378b1fac'
    md5("password"+"message").hexdigest() # 'c494404d2dd827b05e27bd1f30a763d2'
    

    Also take a look at how HMAC is implemented (e.g. on Wikipedia).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this Javascript function that sends username and password to php file through
In this blog, http://www.bswebdev.com/2008/12/javascript-change-input-box-type-to-password/ I have found the following snippets for fixing change input
I have javascript string variable with var sttr=We prefer questions that can be answered
I have some JavaScript code that gives this error: Uncaught TypeError: Cannot read property
I have a simple login form that captures username/password with some simple Javascript (JQuery)
I have javascript code some thing like this -- var count=3; var pl=new Array(count);
I have Javascript function defined in the main index.html file. One part of this
I have Javascript that opens another window and registers a click handler for all
I have JavaScript that is doing activity periodically. When the user is not looking
I have javascript code embedded inside a html template file. When I load this

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.