On Tue, Sep 16, 2008 at 2:40 PM, Arthur C. <[EMAIL PROTECTED]> wrote:
> I have an NSDictionary that has to be written to disk, distributed and read 
> in again.
> I would like to add an MD5 sum to the dictionary to make sure it has not been 
> modified/corrupted on the way. That can be done by making NSData using 
> NSArchiver and then passing it to MD5() from <openssl/md5.h>.
>
> But, the order in which keys/values are stored in the dict is not fixed. I 
> would like to know if there is a simple way to get a unique (reproducable) 
> MD5-sum.

  I'd try adding a category method that gets all the dict's keys,
sorts the keys array, creates an array consisting of the (now-sorted)
key, value-for-that-key, key, value-for-that-key, key,
value-for-that-key ..., then archives the array, then gets the MD5 sum
from that archived array. In other words, the array would simply hold
a series of key string objects, then the object for that key ... for
every key in your sorted key list.

  ... but then, there might be a far easier way of doing it than that.
:-) Just a thought.

--
I.S.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to