Using CryptoSwift

      2 Comments on Using CryptoSwift

CryptoSwift is a very simple and powerful encryption library. In this short article we'll go over the basics of using CryptoSwift and get you started...Privacy is very important today and we have a couple of options to encrypt our users’ data on iOS. We already have common crypto available on iOS but recently I came across a much simpler library that you can use. In this short article we’ll go over the basics of using CryptoSwift and get you started with it…

Install

There are many ways to install CryptoSwift. You can use embedded frameworks, Carthage, pods or even the swift package manager. By far, the easiest way to get started is by using cocoapods. So go ahead and add the library to your podfile and run pod install:

Hopefully, that was pretty uneventful for you πŸ™‚ Now we can cover some basics of what the library can do for you…

Usage

CryptoSwift will have pretty much everything you’ll need. Some of the things that you’ll most definitely use are digests and, well, encryption πŸ™‚ Using digests is incredibly simple because of the string, array and data extensions that you get for free. Check out this example of using some common digests:

Pretty simple, right πŸ™‚

In this next example we’re encrypting a string using a Rabbit stream cipher and converting it to base 64. It sounds more complicated than it really is:

Of course, decryption works in reverse, as you would expect πŸ™‚

One last example we’ll cover today is the famous AES cipher. Using it is pretty much the same as using the above cipher:

The encrypt function takes in a utf8 array so we have to convert the string to it. And that’s pretty much it for today πŸ™‚

Conclusion

This certainly wasn’t a long article. But the CryptoSwift library is so simple to use that it didn’t have to be πŸ™‚ It’s a great replacement for common crypto and is so much easier to use. CryptoSwift is very popular on GitHub and is actively maintained, so you know it won’t disappear over night πŸ™‚

I just thought I’d share this great find with you this week and I hope it’ll help you out in your development. You can find the very short example on GitLab and you can always go and check out CryptoSwift on GitHub and they also have a website.

I told you it was going to be a short one today πŸ™‚ As always…

Have a nice day πŸ™‚
~D;

More resources

2 thoughts on “Using CryptoSwift

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.