Skip to content

An Objective-C implementation of CRC32b checksum, MD5, SHA1 and SHA512 hash algorithms. Performs it chunked and consumes almost no memory while running, making it suitable to both OSX and iOS.

License

Notifications You must be signed in to change notification settings

leetal/AWFileHash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWFileHash

CI Status Version License Platform

A security library that supports md5, sha1 and sha512 hashes. Performs all calculations chunked to reduce memory impact (does not apply to PHAsset as of now).

Returns a hex of the result.

Requirements

iOS5+ is required. If using cocoapods, min version in podfile is iOS7. For PHAsset support iOS8+ is required.

Usage/Examples

// Filepath (file accessible on disk)
NSString *_filePath = ...
NSString *md5 = [AWFileHash md5HashOfFileAtPath:_filePath]

// NSData
NSData *_data = [NSData dataWithBytes:"AWFileHash" length:10];
NSString *md5 = [AWFileHash md5HashOfData:_data];

// ALAssetRepresentation
ALAsset *_asset = ...
ALAssetRepresentation *_assetRep = [_asset defaultRepresentation];
NSString *md5 = [AWFileHash md5HashOfALAssetRepresentation:_assetRep];

For SHA1 or SHA512 support, just replace the "md5" in the names to "sha1" or "sha512".

Installation

Make sure to include AWFileHash.h where you want to use the lib.

Cocoapods

AWFileHash is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "AWFileHash"

Manual

Download the .zip, unpack it and draw the files "AWFileHash.{m,h}" into XCode. Make sure to add them to your target bundle also.

TODO

  • Add support for PHAsset (need to find a way to stream bytes to AWFileHash)
  • Add md5 categories for NSString & NSData
  • Add proper documentation
  • Add more tests that conform to the standards

Definitions

Specifications:

Author

Alexander Widerberg, widerbergaren [at] gmail.com

License

AWFileHash is available under the MIT license. See the LICENSE file for more info.

About

An Objective-C implementation of CRC32b checksum, MD5, SHA1 and SHA512 hash algorithms. Performs it chunked and consumes almost no memory while running, making it suitable to both OSX and iOS.

Resources

License

Stars

Watchers

Forks

Packages

No packages published