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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:07:34+00:00 2026-06-07T09:07:34+00:00

As per the various docs that I have read for using HMAC SHA256, I

  • 0

As per the various docs that I have read for using HMAC SHA256, I have understood that:

H (K XOR opad, H (K XOR ipad, text)) where H in my case is SHA256.

But, SHA256 input has only one parameter i.e a Message.
Whereas H(K,text) has two inputs.
So how to calculate H(k,text)?

Should I first encode text with k and then use H(encoded_text), where encoded_text will be used as a message?

Thank You

  • 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-07T09:07:36+00:00Added an answer on June 7, 2026 at 9:07 am
    • H() is your cryptographic hash function, in this case SHA256() but
      could also be MD5 or whatever;
    • K is your predifined key
    • Text is the message to be authenticated
    • opad be the outer padding (0x5c5c5c…5c5c, one-block-long hexadecimal
      constant)
    • ipad be the inner padding (0x363636…3636, one-block-long hexadecimal
      constant)
    • Then HMAC(K,m) is mathematically defined by

    HMAC(K,m) = H((K ⊕ opad) ∥ H((K ⊕ ipad) ∥ m)).

    • blocksized is determined by your hash function (MD5 would be 64
      bytes)
    • o_key_pad = [opad * blocksize] ⊕ key
    • i_key_pad = [ipad * blocksize] ⊕ key

    Your result would be:

    H(o_key_pad || H(i_key_pad || TEXT))
    

    You can find a good read here:
    http://timdinh.nl/index.php/hmac/

    With also the following pseudocode which almost looks like mine :

    function hmac (key, message)
        opad = [0x5c * blocksize] // Where blocksize is that of the underlying hash function
        ipad = [0x36 * blocksize]
    
        if (length(key) > blocksize) then
            key = hash(key) // Where 'hash' is the underlying hash function
        end if
    
        for i from 0 to length(key) - 1 step 1
            ipad[i] = ipad[i] XOR key[i]
            opad[i] = opad[i] XOR key[i]
        end for
    
        return hash(opad || hash(ipad || message)) // Where || is concatenation
    end function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a server that receives various xml messages from clients (one thread per
I'm wondering about standards or commonalities for various common elements on webpages that have
I have a script that is getting the GeoIP locations of various ips, this
Per a great answer from another question I have begun mounting global resources (css/js/images)
I am dealing with a master page split into various content placeholders as per
Checked various questions on SO, but found nothing that quite matches what I'm after...
I am trying to pull text from various parts of a webpage and push
In Salesforce you can set up various workflow processes or build API apps that
As per the requirement, I have parsed an XML file and set data into
Over the years I have noticed the 'wildcard' variable in various bits and pieces

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.