Cryptography

A modern cryptography library in Swift

15
4
Swift

Cryptography

Language Platform MIT licensed
Build Status Code Quality Code Coverage Doc Coverage
CocoaPods Carthage


A modern cryptography library in Swift.

FeaturesUsageInstallationDocumentationAuthorLicense

Features

  • [x] Hash Functions
    • MD5
    • SHA-1
    • SHA-2 (SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, SHA-512/256)
    • SHA-3
  • [x] Message Authentication Codes
    • HMAC (via: SHA-3/SHA-2/SHA-1/MD5)

Soon to come

  • [ ] High Speed Stream Ciphers
    • ChaCha
    • Panama
    • Sosemanuk
    • Salsa20
  • [ ] block ciphers
    • AES (Rijndael)
    • Triple-DES (DES-EDE2 and DES-EDE3)
    • Blowfish
    • RC5
  • [ ] Message Authentication Codes
    • VMAC
    • CMAC
    • GMAC
  • [ ] Hash Functions
    • BLAKE2s
    • BLAKE2b
    • RIPEMD
  • [ ] Public-Key Cryptography
    • RSA
    • DSA
    • ElGamal
    • Nyberg-Rueppel (NR)
    • Rabin-Williams (RW)
  • [ ] Key Agreement Schemes
    • Diffie-Hellman (DH)
    • Unified Diffie-Hellman (DH2)
  • [ ] Elliptic Curve Cryptography
    • ECDSA
    • ECNR
    • ECIES

Usage

First import Cryptography module.

import Cryptography

Everything you need is available via the Cryptography facade.

Hash Functions

In order to calculate a hash value you simply call Cryptography.hash(message: String, method: HashMethod) -> String with the desired HashMethod

let hashValue = Cryptography.hash("The quick brown fox jumps over the lazy dog", method: HashMethod.SHA1) // "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12"

Message Authentication Codes

In order to calculate a MAC value you simply call authenticate(message: String, key: String, method: MACMethod) -> String with the desired MACMethod

let macValue = Cryptography.authenticate("The quick brown fox jumps over the lazy dog", key: "key", method: MACMethod.HMAC(hashMethod: HashMethod.SHA1)) // "de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9"

Installation

Compatibility

  • OS X 10.9+ / iOS 8.0+ / watchOS 2.0 / tvOS 9.0

  • Xcode 7.1+, Swift 2.1+

Install Using CocoaPods

CocoaPods is a centralized dependency manager for
Objective-C and Swift. Go here
to learn more.

  1. Add the project to your Podfile.

    use_frameworks!
    
    pod 'Cryptography'
    
  2. Run pod install and open the .xcworkspace file to launch Xcode.

Install Using Carthage

Carthage is a decentralized dependency
manager for Objective-C and Swift.

  1. Add the project to your Cartfile.

    github "mlachmish/Cryptography"
    
  2. Run carthage update and follow the additional steps
    in order to add Cryptography to your project.

###Swift Package Manager
You can use Swift Package Manager and specify dependency in Package.swift by adding this:

.Package(url: "https://github.com/mlachmish/Cryptography.git", majorVersion: 0)

Manually

Download and drop /Cryptography folder in your project.

Author

Matan Lachmish a.k.a The Big Fat Ninja The Big Fat Ninja

https://thebigfatninja.xyz

Audit & Security Disclosure

If you believe you have identified a security vulnerability with Cryptography,

please report it as soon as possible via email to [email protected]

Do not post it to the public issue tracker.

attribution

Icon made by Freepik from www.flaticon.com

License

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