<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Objective-C SHA1 Function for the iPhone</title>
	<atom:link href="http://spitzkoff.com/craig/?feed=rss2&#038;p=122" rel="self" type="application/rss+xml" />
	<link>http://spitzkoff.com/craig/?p=122</link>
	<description>Craig&#039;s blog about Life and Software Development</description>
	<lastBuildDate>Fri, 27 Aug 2010 16:21:27 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Calculer le hash digest SHA1 en objective-C &#171; My iPhone development scrapbook</title>
		<link>http://spitzkoff.com/craig/?p=122&#038;cpage=1#comment-439</link>
		<dc:creator>Calculer le hash digest SHA1 en objective-C &#171; My iPhone development scrapbook</dc:creator>
		<pubDate>Fri, 27 Aug 2010 12:44:28 +0000</pubDate>
		<guid isPermaLink="false">http://spitzkoff.com/craig/?p=122#comment-439</guid>
		<description>[...] le hash digest SHA1 en&#160;objective-C  Je suis tombé sur cette fonction donné sur The Reluctant Blogger, cette fonction retourne le hash sha1 équivalent à la fonction php [...]</description>
		<content:encoded><![CDATA[<p>[...] le hash digest SHA1 en&nbsp;objective-C  Je suis tombé sur cette fonction donné sur The Reluctant Blogger, cette fonction retourne le hash sha1 équivalent à la fonction php [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Lorenz</title>
		<link>http://spitzkoff.com/craig/?p=122&#038;cpage=1#comment-389</link>
		<dc:creator>Mark Lorenz</dc:creator>
		<pubDate>Sat, 24 Apr 2010 18:13:23 +0000</pubDate>
		<guid isPermaLink="false">http://spitzkoff.com/craig/?p=122#comment-389</guid>
		<description>The PHP SHA1() function uses ASCII encoding.  You can verify this by digesting a string containing something like &quot;Ň&quot;  with your code, and with PHPs SHA1().  As long as  your input string is guaranteed to contain only ASCII characters it will work fine.

I suggest updating the code to:
-(NSString*) digest:(NSString*)input{
	NSData *data = [input dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
	uint8_t digest[CC_SHA1_DIGEST_LENGTH];
	CC_SHA1(data.bytes, data.length, digest);
	NSMutableString* output = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH * 2];
	
	for(int i = 0; i &lt; CC_SHA1_DIGEST_LENGTH; i++)
		[output appendFormat:@&quot;%02x&quot;, digest[i]];
	
	return output;
}</description>
		<content:encoded><![CDATA[<p>The PHP SHA1() function uses ASCII encoding.  You can verify this by digesting a string containing something like &#8220;Ň&#8221;  with your code, and with PHPs SHA1().  As long as  your input string is guaranteed to contain only ASCII characters it will work fine.</p>
<p>I suggest updating the code to:<br />
-(NSString*) digest:(NSString*)input{<br />
	NSData *data = [input dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];<br />
	uint8_t digest[CC_SHA1_DIGEST_LENGTH];<br />
	CC_SHA1(data.bytes, data.length, digest);<br />
	NSMutableString* output = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH * 2];</p>
<p>	for(int i = 0; i &lt; CC_SHA1_DIGEST_LENGTH; i++)<br />
		[output appendFormat:@&quot;%02x&quot;, digest[i]];</p>
<p>	return output;<br />
}</p>
]]></content:encoded>
	</item>
</channel>
</rss>
