Skip to content
Makes calculating digests easy.
Objective-C
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
CBHDigestKit.xcodeproj
CBHDigestKit
CBHDigestKitTests
.gitattributes
.gitignore
CBHDigestKit.podspec
LICENSE
README.md

README.md

CBHDigestKit

release pod licence coverage

Makes calculating digests easy.

Supports:

  • SHA-224
  • SHA-256
  • SHA-386
  • SHA-512
  • SHA-1
  • MD2
  • MD4
  • MD5

Use

CBHDigestKit extends NSData and NSString with a category adding methods for several digests and converting from bytesToHex.

Example:

Compute the SHA-256 digest of a NSString:

NSData *digest = [@"This is a string." sha256UsingEncoding:NSUTF8StringEncoding];

Compute the SHA-256 digest of a NSData:

NSData *digest = [[NSData dataWithContentsOfFile:@"/etc/hosts"] sha256];

Efficently compute the SHA-256 digest of a file:

NSData *digest = [CBHDigester digestStream:[NSInputStream inputStreamWithFileAtPath:@"/etc/hosts"];

Compute and print a digest using an arbitrary algorithm:

CBHDigestAlgorithm algorithm = ...
NSData *data = [NSData dataWithContentsOfFile:@"/etc/hosts"];
NSData *digest = [data digestUsingAlgorithm:algorithm];
NSLog(@"0x%@", [digest bytesToHex]);

Licence

CBHDigestKit is available under the ISC license.

You can’t perform that action at this time.