Latest 0.0.1
Homepage https://github.com/saiyuujob/CryptoWithSwift
License MIT
Platforms ios 9.0
Authors

Wrapped CommonCrypto(CommonCrypto/CommonCrypto.h) with swift

  • Encryption algorithm: AES
  • Encryption mode: CBC
  • Padding method: PKCS7Padding
  • Key length: 256

Installation

To install CryptoWithSwift, add it as a submodule to your project

Usage

import CryptoWithSwift

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        let testText = "Hello. CryptoWithSwfit"
        let key = "D8DDA1ED-BFFC-47E6-8393-2941F8FB0E6D"    //UUID().uuidString
        let iv =  "Rhm9BB36QA8="                            //CryptoWithSwift.generateRandomBytes(byteCount: 8)
        var afterEncryption: String?

        // Encryption
        if let retEncryption = CryptoWithSwift.AES256CBCEncryption(target: testText, key: key, iv: iv) {
            print("encryption success: (retEncryption)")
            afterEncryption = retEncryption
        } else {
            print("encryption failure.")
        }

        // Decrypt
        if let encryption = afterEncryption {
            if let retDecrypt = CryptoWithSwift.AES256CBCDecrypt(target: encryption, key: key, iv: iv) {
                print("decrypt success: (retDecrypt)")
            } else {
                print("decrypt failure.")
            }
        }
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }   
}

License

MIT

Latest podspec

{
    "name": "CryptoWithSwift",
    "version": "0.0.1",
    "summary": "Encryption and Decrypt",
    "description": "Wrapped CommonCrypto(CommonCrypto/CommonCrypto.h) with swift",
    "homepage": "https://github.com/saiyuujob/CryptoWithSwift",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "saiyuu": "[email protected]"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/saiyuujob/CryptoWithSwift.git",
        "tag": "0.0.1"
    },
    "source_files": "*"
}

Pin It on Pinterest

Share This