title: How to hash NSString with SHA1 in Swift?
body: <p>In objective-c it looks like this:</p>
  
  <pre><code>#include &lt;sys/xattr.h&gt;
  
  @implementation NSString (reverse)
  
  -(NSString*)sha1
  {
      NSData *data = [self dataUsingEncoding:NSUTF8StringEncoding];
      uint8_t digest[CC_SHA1_DIGEST_LENGTH];
      CC_SHA1(data.bytes, (int)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:@"%02x", digest[i]];
      return output;
  }
  
  @end
  </code></pre>
  
  <p>I need something like this with Swift, is it possible?</p>
  
  <p>Please, show work example.</p>