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 8181669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:35:57+00:00 2026-06-07T00:35:57+00:00

OpenSSL::HMAC#hexdigest (using MD5) vs Digest::MD5#hexdigest what are the differences and/or advantages? Couldn’t you just

  • 0

OpenSSL::HMAC#hexdigest (using MD5) vs Digest::MD5#hexdigest what are the differences and/or advantages? Couldn’t you just use Digest::MD5#hexdigest(KEY + DATA) or is that consider cryptographically weak?

  • 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-06-07T00:35:58+00:00Added an answer on June 7, 2026 at 12:35 am

    The HMAC-MD5 of DATA and KEY is define as

    MD5( (K xor pad1) + H ((K xor pad2) + DATA )
    

    where pad1 and pad2 are two fixed constants. Some of the more obvious things you might do are cryptographically weak.

    Digest::MD5.hexdigest(KEY + DATA)
    

    is fatally flawed. Consider how MD5 works. It splits the input up into blocks of a certain size (512 bits for md5) and sets up some initial state h0, h1, h2, h3. It then does a bunch of transformations to mix the first block of data with that initial state to produce new values of h0, h1, h2, h3. The second block of data is then combined with those to produce a new set of h0,h1,h2,h3 and so on. The final value of the hash function is just the concatenation of h0,h1,h2,h3.

    This means that if you give me Digest::MD5#hexdigest(KEY + DATA) then I can calculate what Digest::MD5#hexdigest(KEY + DATA + OTHER_DATA) is without knowing KEY at all. You can do the same thing with SHA1

    If instead you did

    Digest::MD5.hexdigest(DATA+KEY)
    

    then any known collisions in MD5 are easily used to make messages with the same HMAC value.

    Apparently

    Digest::MD5.hexdigest(KEY+DATA+KEY)
    

    may be flawed too, even if two different keys were used. HMAC was designed to mitigate all of these attacks.

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

Sidebar

Related Questions

So I have some code: signature = hmac.new( key=AWS_SECRET_ACCESS_KEY, msg=string_to_sign, digestmod=hashlib.sha256).digest() That runs perfectly
I am trying to take an AES HMAC of a file using the openssl
i'm working with some codes that has a: begin require 'digest/hmac' USE_EMBEDDED_HMAC = false
I am using openssl APIs for AES in my code. What I noticed that
Ruby code: a = OpenSSL::HMAC.digest('sha1', 'secret', 'example') and then: Base64.encode64(a).chomp yields aMp6Zw1+hHVMmwWXoFp/Aaipc20= iPhone: +
When using openssl I've been taught to use RAND_load_file and RAND_write_file to ensure the
I want to create a signature for a file using OpenSSL. I believe that
When using OpenSSL with non blocking sockets its convenient to use the transparent negotiation
I use openssl and mysql encryption trough PHP. Currently, I write the key in
For using openSSL API for public key encryption, how is the key (public &

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.