Giter VIP home page Giter VIP logo

awfilehash's Introduction

AWFileHash

CI Status Version License Platform

A security library that supports md5, sha1 and sha512 hashes, as well as CRC32b checksums. 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 or Swift, min version in podfile/build is iOS8. For PHAsset support iOS8+ is required.

Usage/Examples

Swift

import AWFileHash
...
...
let data:NSData = NSData(data: "AWFileHash", length: 10)
let hash = AWFileHash.md5HashOfData(data)
print(hash)

Objective-C

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

// 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, SHA512 or CRC32b support, just replace the "md5" in the names to "sha1", "sha512" or "crc32" respectively.

Installation

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.

awfilehash's People

Contributors

leetal avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.