Mike, thank you for the explanation,
I am using NSData to unbencode the torrent file.
ans sucessfully store it to a NSDictionary, "plist" so i can read it outside the software.
that works just fine...

The sha1 hash data is embedded raw, right in the file.
No escaping is done, because there is no need: the length of the data is given in the file.

The Data that needs to be used to create the SHA1 Hash is the data of the "info" key in raw bencoded form.

How would you go about extracting just that part of the data, if converting it to string is not the right way to go.
This is how i do it :  but obviously this does not work.

NSData *torrentData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:itemLink]];
if (0 < [torrentData length]){
NSString *torrentString = [[[NSString alloc]initWithData:torrentData encoding:NSASCIIStringEncoding]autorelease];
        // find the range of the info section.
NSRange infoRange = [torrentString rangeOfString:@"4:info" options:NSCaseInsensitiveSearch]; torrentString = [torrentString substringFromIndex:(infoRange.location + infoRange.length)]; torrentString = [torrentString substringToIndex:[torrentString length]];
        NSString *infoHash = [torrentString sha1HexHash];
}

sorry Honestly I had no clue that string escaping was so broad, if i did, i'd never chosen that subject :) thanks for explaining, there is no mention on the documentation on what type of escaping that need to be done
on the torrent data.

Thank you for your help.
Sandro
_______________________________________________

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