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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:19:48+00:00 2026-06-10T15:19:48+00:00

When using HMAC to authenticate an API call, often the message to be hashed

  • 0

When using HMAC to authenticate an API call, often the message to be hashed includes a lot of stuff that doesn’t seem to add anything. For example, here are the steps for a generating the signature for an API:

hmacsha1(HTTP VERB + URI + JSON_REQUEST_CONTENT + DATETIME, "secret")

Why not just go like:

hmacsha1(JSON_REQUEST_CONTENT, "secret")

This is assuming that JSON_REQUEST_CONTENT is a JSON string that contains all of the relevant request information.

It seems to me like adding the HTTP VERB and URI (or whatever extra non-content-specific info) is just adding to the length of the message, and I don’t understand the benefit.

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-06-10T15:19:50+00:00Added an answer on June 10, 2026 at 3:19 pm

    HMACs are generally used to prevent message tampering, but they are also used to prevent replay of messages.

    If the HMAC only included the payload and a secret that would only prevent tampering, if I sent the same message again it would be valid. By garnishing the request with other details (datetime or a nonce especially) that should prevent replay as well as tampering.


    To use the datetime as salt for the hash, you generally will need to send the datetime with the message in clear text (although it could be roughly inferred from the time the message was received or sent in the request headers external to the payload). If the datetime is too far from what the server believes the time to be, the message will fail (e.g. not within a minute). If when the server does the same hash on the data and it doesn’t get the same result, it will also fail the message.

    To use a nonce, the most practical way is for the service to say, next time you send me a request, use this nonce. The nonce doesn’t need to be sent in clear text with the request. When the server processes a message successfully, it says, next time use this nonce and the previous one becomes invalid.

    Datetime prevents replay by ensuring that a message was sent at a specific time, a nonce prevents replay by using a single use password.

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

Sidebar

Related Questions

As per the various docs that I have read for using HMAC SHA256, I
I am writing an application which has an authenticity mechanism, using HMAC-sha1, plus a
Using PHP, I am encoding passwords using the hmac function with the sha256 algorithm.
OpenSSL::HMAC#hexdigest (using MD5) vs Digest::MD5#hexdigest what are the differences and/or advantages? Couldn't you just
I am trying to take an AES HMAC of a file using the openssl
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
I have a single view that handles a lot of Models of type VoyagesViewModel,
There is an example HMAC-SHA1 here that works in javascript http://jssha.sourceforge.net/ Text to encrypt
i'm working with some codes that has a: begin require 'digest/hmac' USE_EMBEDDED_HMAC = false
I am accessing Google Spreadsheet feeds using HMAC-SH1 sign. My Code is : GoogleOAuthParameters

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.