sha256 hashing algorithm on objective c fails to create a hash that matches the hash generated on the server
<p>I am using the following code to create a sha256 hash of a file, that gets compared against a hash created downstream.
The hash created by my code appears to fail very intermittently.</p>

<pre><code>    unsigned char hash[CC_SHA256_DIGEST_LENGTH];

if ( CC_SHA256([data bytes], [data length], hash) ) {

    NSData *sha256 = [NSData dataWithBytes:hash length:CC_SHA256_DIGEST_LENGTH];


    NSString *hash=[sha256 description];
    hash = [hash stringByReplacingOccurrencesOfString:@" " withString:@""];
    hash = [hash stringByReplacingOccurrencesOfString:@"&lt;" withString:@""];
    hash = [hash stringByReplacingOccurrencesOfString:@"&gt;" withString:@""];

    return hash;
}
return nil;
</code></pre>

<p>Hope someone can help me with this? The hash gets generated properly 99.9% of the time, but does fails rarely.</p>

<p>Edit:
to clarify, 
The hash generated on my code is the same as the hash generated by the server most of the time.
intermittently, however, the hash generated does not match the one generated downstream.
We checked the file with one of the online hashing sites, and the hash generated by the server was correct, while mine did not match the hash generated by the site(defuse.ca)</p>