title: Generate SHA256 String in Objective C
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3709204/sha256-in-objective-c-for-iphone">Sha256 in Objective-C for iPhone</a>  </p>
  </blockquote>
  
  
  
  <p>Greetings,</p>
  
  <p>I'm having terrible trouble generating a SHA256 string in Objective C (probably because I'm so new to the language).</p>
  
  <p>In jQuery, all I have to do is this:</p>
  
  <pre><code>var sha256String=$.sha256("Hello");
  </code></pre>
  
  <p>which produces the hash as expected.</p>
  
  <p>But in Objective-C, I've tried the following to no avail:</p>
  
  <pre><code>NSString *pword=[[NSString alloc]
  initWithString:login_pword.text];
  unsigned char result[64];
  CC_SHA256([pword UTF8String], [pword lengthOfBytesUsingEncoding:NSASCIIStringEncoding],result);
  UIAlertView *msg=[[UIAlertView alloc] initWithTitle:@"Hi" message:result delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
  [msg show];
  [msg release];
  </code></pre>
  
  <p>Is there some function that I can call such as:</p>
  
  <pre><code>NSString *sha256String=[self getSHA256:pword];
  </code></pre>
  
  <p>This is what I'm trying to create and I'm finding it very difficult!</p>
  
  <p>I hope someone can help.</p>
  
  <p>Many thanks in advance,</p>