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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:50:50+00:00 2026-06-04T16:50:50+00:00

When calling hash on the built in NSData class in the foundation framework —

  • 0

When calling hash on the built in NSData class in the foundation framework — what implementation is used to return the hash value? (CRC32, something else?)

  • 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-04T16:50:51+00:00Added an answer on June 4, 2026 at 4:50 pm

    Something else. Actually it’s an implementation detail, which does not need to use a fixed algorithm in different versions.

    You can check the implementation in the open source version of Core Foundation. Note that NSData is toll-free bridged to CFDataRef. From http://opensource.apple.com/source/CF/CF-635.21/CFData.c:

    static CFHashCode __CFDataHash(CFTypeRef cf) {
        CFDataRef data = (CFDataRef)cf;
        return CFHashBytes((uint8_t *)CFDataGetBytePtr(data), __CFMin(__CFDataLength(data), 80));
    }
    

    we see that the first 80 bytes are used to compute the hash. The function CFHashBytes is implemented as using the ELF hash algorithm:

    #define ELF_STEP(B) T1 = (H << 4) + B; T2 = T1 & 0xF0000000; if (T2) T1 ^= (T2 >> 24); T1 &= (~T2); H = T1;
    
    CFHashCode CFHashBytes(uint8_t *bytes, CFIndex length) {
        /* The ELF hash algorithm, used in the ELF object file format */
        UInt32 H = 0, T1, T2;
        SInt32 rem = length;
        while (3 < rem) {
        ELF_STEP(bytes[length - rem]);
        ELF_STEP(bytes[length - rem + 1]);
        ELF_STEP(bytes[length - rem + 2]);
        ELF_STEP(bytes[length - rem + 3]);
        rem -= 4;
        }
        switch (rem) {
        case 3:  ELF_STEP(bytes[length - 3]);
        case 2:  ELF_STEP(bytes[length - 2]);
        case 1:  ELF_STEP(bytes[length - 1]);
        case 0:  ;
        }
        return H;
    }
    
    #undef ELF_STEP
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm interested in getting the nested 'name' parameter of a params hash. Calling something
Code example below. Calling append on a hash value returns correctly but the hash
I am calling getTags web-method which returns hash-table in JSON format. following is return
//calling class import javax.swing.JFrame; class jcheckkbox { public static void main(String args[]) { jRadio
When calling functions that always throw from a function returning a value, the compiler
i'm having trouble with modifying the location hash in IE8 for XP. simply calling:
I have a hash object from an ActiveRecord. I'm going to be calling to_json
I have a db column which is a serialized Hash : class Foo <
I want to create a Config class that acts somewhere between a hash and
When calling each on a hash in ruby, you can get the key and

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.