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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:15:00+00:00 2026-05-29T20:15:00+00:00

I’m currently developing an app which needs to send authentication data with it to

  • 0

I’m currently developing an app which needs to send authentication data with it to a provided API. Basically it needs to generate a hash based on the data you want to send, based on a shared key.

The problem is that while I have been able to track down functions that will do MD5 hashing, they are not based on a key, which is absolutely crucial.

Is there any way this can be done in objective-c for the iOS platform?

The API is usually used with PHP, which provides something like this handy function:

$key = hash_hmac('md5', $postdata , $sharedkey);

Is there any chance of implementing an equal in objective-c?

  • 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-29T20:15:03+00:00Added an answer on May 29, 2026 at 8:15 pm

    The MD5 algorithm only uses one string as input. The convention is that you append your key (aka “salt” value) to the string you are hashing. My guess is that the PHP MD5 function has a second parameter for the key to make life easier, but you should get the same result if you just do this:

    NSString *value = [data stringByAppendingString:key];
    NSString *hashed = MD5HASH(value); //pseudocode
    

    UPDATE:

    Okay, I checked Wikipedia and it looks like you need to do a bit of extra work to implement HMAC-style hashing. So you have two options.

    1. Implement the HMAC algorithm on top of the MD5 hash you’re already using (it doesn’t look too hard – I’ve pasted the pseudocode below).

    2. Don’t bother with HMAC – just generate the hash at both ends using a regular MD5 by concatenating the message and the key – that should be pretty secure, it’s what most people do.

    HMAC algorithm

    function hmac (key, message)
        if (length(key) > blocksize) then
            key = hash(key) // keys longer than blocksize are shortened
        end if
        if (length(key) < blocksize) then
            key = key ∥ [0x00 * (blocksize - length(key))] // keys shorter than blocksize are zero-padded ('∥' is concatenation) 
        end if
    
        o_key_pad = [0x5c * blocksize] ⊕ key // Where blocksize is that of the underlying hash function
        i_key_pad = [0x36 * blocksize] ⊕ key // Where ⊕ is exclusive or (XOR)
    
        return hash(o_key_pad ∥ hash(i_key_pad ∥ 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

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has
I am currently running into a problem where an element is coming back from
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I have a text area in my form which accepts all possible characters from

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.