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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:23:58+00:00 2026-06-02T18:23:58+00:00

I am attempting to compute a MD5 hash within an iOS app, in an

  • 0

I am attempting to compute a MD5 hash within an iOS app, in an effort to compare hashes between the file saved within the app and the same file stored on a web server using PHP.

This is the code for the iOS app:

unsigned char result[CC_MD5_DIGEST_LENGTH];

NSData* data = [NSData dataWithContentsOfFile:@"advert.png"];
const void* src = [data bytes];

CC_MD5(src, [data length], result);

    NSString *imageHash = [[NSString stringWithFormat:
                       @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
                       result[0], result[1], result[2], result[3], 
                       result[4], result[5], result[6], result[7],
                       result[8], result[9], result[10], result[11],
                       result[12], result[13], result[14], result[15]]
                       lowercaseString];

NSLog(@"%@", imageHash);

The code for the web server:

$file = 'advert.png';
echo 'MD5 file hash of ' . $file . ': ' . md5_file($file);

The app generates: D41D8CD98F00B204E9800998ECF8427E

The PHP generates: 3ef9386b1dd50e8e166efbe48f0f9401

md5sum generates: 3ef9386b1dd50e8e166efbe48f0f9401

UPDATE:

Just ran the app through the simulator and it correctly computes the hash: 3ef9386b1dd50e8e166efbe48f0f9401.

When ran on my iPhone 4 running iOS 5.1 it calculates as: ddf017003e063e353a5e4ec2cc4a5095

  • 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-02T18:24:00+00:00Added an answer on June 2, 2026 at 6:24 pm

    D41D8CD98F00B204E9800998ECF8427E is the MD5 sum of an empty file. Your don’t read the file correctly, the reason is probably that dataWithContentsOfFile: needs an absolute path.
    Try:

    NSString *path = [[NSBundle mainBundle] pathForResource:@"advert" ofType:@"png"];
    NSData *plistData = [NSData dataWithContentsOfFile:path];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to use the Microsoft crypto APIs to compute an MD5 hash, but
Attempting/struggling to get registration and sign-up working within an active admin project. I have
Im attempting to load a hex literal from an xml settings file, I can
I am attempting to make an app in which you can load an image
I'm attempting to implement an easter egg in a mobile app I'm working on.
I'm attempting to use jqgrid. Unfortunately, I can't compute a resultset size because I'm
I am attempting to determine if I can compute the sum of two 32
I am attempting to deploy a simple f# console app to a coworkers computer
Attempting to use the data series from this example no longer passes the JSONLint
Attempting to make a NSObject called 'Person' that will hold the login details for

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.