Giter VIP home page Giter VIP logo

nshash's Introduction

NSHash adds hashing methods to NSString and NSData.

Use it

Copy the NSHash class into your project or add this line to your Podfile

pod 'NSHash', '~> 1.0.0'

Quick API overview

Import the the category class you need:

#import <NSHash/NSData+NSString.h>
#import <NSHash/NSData+NSHash.h>

After that you can call MD5, SHA1 and SHA256 on any NSString:

NSString* string = @"NSHash";
NSLog(@"MD5:    %@", [string MD5]);
NSLog(@"SHA1:   %@", [string SHA1]);
NSLog(@"SHA256: %@", [string SHA256]);

This will return a new NSString with a hex code transformed version of the hash:

MD5:    ccbe85c2011c5fe3da7d760849c4f99e
SHA1:   f5b17712c5d31ab49654b0baadf699561958d750
SHA256: 84423607efac17079369134460239541285d5ff40594f9b8b16f567500162d2e

Or call MD5, SHA1 and SHA256 on any NSData:

NSData* data = [@"NSHash" dataUsingEncoding:NSUTF8StringEncoding];
NSLog(@"MD5:    %@", [data MD5]);
NSLog(@"SHA1:   %@", [data SHA1]);
NSLog(@"SHA256: %@", [data SHA256]);

Which will return the NSData with the hash as bytes without the hex transformation:

MD5:    <ccbe85c2 011c5fe3 da7d7608 49c4f99e>
SHA1:   <f5b17712 c5d31ab4 9654b0ba adf69956 1958d750>
SHA256: <84423607 efac1707 93691344 60239541 285d5ff4 0594f9b8 b16f5675 00162d2e>

Feedback are welcome

Please fill an issue for any feedback or if you missed any other convenience method.

nshash's People

Contributors

jerolimov avatar

Watchers

Jérôme Morissard 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.