Skip to content

Commit

Permalink
Changed the readme file to note the Swift3.0 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
sgl0v committed Sep 29, 2016
1 parent bfd0f7a commit f0dd55c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 24 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@
All notable changes to this project will be documented in this file.
`SCrypto` adheres to [Semantic Versioning](http://semver.org/).

- `2.x` Releases - [2.0.0](#200)
- `1.x` Releases - [1.0.0](#100) | [1.0.1](#101) | [1.0.2](#102)

---

## [2.0.0](https://github.com/sgl0v/SCrypto/releases/tag/2.0.0)
Released on 2016-09-29.

#### Updates
- Swift 3.0 support.

---

## [1.0.2](https://github.com/sgl0v/SCrypto/releases/tag/1.0.2)
Released on 2016-04-18.

Expand Down
29 changes: 14 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
SCrypto provides neat Swift interface to access the CommonCrypto routines.
### Features

- [x] Essential `NSData` and `String` extensions for message digest, HMAC, PBKDF, symmetric encryption calculation
- [x] Swift 2.0 and Swift 2.2 support
- [x] Essential `Data` and `String` extensions for message digest, HMAC, PBKDF, symmetric encryption calculation
- [x] Swift 2.2 and Swift 3.0 support
- [x] Cocoapods and Carthage compatible
- [x] Comprehensive Unit Test Coverage
- [x] [Complete Documentation](http://cocoadocs.org/docsets/SCrypto)
Expand All @@ -27,10 +27,9 @@ SCrypto provides neat Swift interface to access the CommonCrypto routines.

##Requirements

- iOS 9.0 or later
- OSX 10.11 or later
- Swift 2.0+
- Xcode 7.3+
- iOS 9.0+ / macOS 10.11+
- Swift 3.0+
- Xcode 8.0+

---

Expand All @@ -50,7 +49,7 @@ source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

pod 'SCrypto', '~> 1.0.0'
pod 'SCrypto', '~> 2.0.0'
```

Then, run the following command:
Expand Down Expand Up @@ -120,16 +119,16 @@ let sha256 = "message".SHA256()
Hash-based message authentication codes (or HMACs) provides a way for calculating message authentication codes using a cryptographic hash function coupled with a secret key. You can use an HMAC to verify both the integrity and authenticity of a message. The following standard hash algorithm are supported: SHA1, MD5, SHA256, SHA384, SHA512, SHA224.

```swift
let secretKey = try! NSData.random(32)
let message = "message".dataUsingEncoding(NSUTF8StringEncoding)!
let secretKey = try! Data.random(32)
let message = "message".data(using: String.Encoding.utf8)!
let hmac = message.hmac(.SHA256, key: secretKey)
```

### Pseudorandom number generator ([PRNG](https://en.wikipedia.org/wiki/Pseudorandom_number_generator))
Generates cryptographically strong random bits suitable for use as cryptographic keys, IVs, nonces etc.

```swift
let randomBytes = try! NSData.random(16)
let randomBytes = try! Data.random(16)
```

### Symmetric-key algorithms ([AES](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard), [DES](https://en.wikipedia.org/wiki/Data_Encryption_Standard), [TripleDES](https://en.wikipedia.org/wiki/Triple_DES), [CAST](https://en.wikipedia.org/wiki/CAST5), [RC2](https://en.wikipedia.org/wiki/RC2), [RC4](https://en.wikipedia.org/wiki/RC4), [Blowfish](https://en.wikipedia.org/wiki/Blowfish_(cipher)))
Expand All @@ -139,9 +138,9 @@ Symmetric-key algorithms use the same cryptographic keys for both encryption of
Here is the way to encrypt and decrypt data via AES algorithm in CBC mode with PKCS7 Padding:

```swift
let plaintext = "plain text".dataUsingEncoding(NSUTF8StringEncoding)!
let sharedSecretKey = "shared_secret_key".dataUsingEncoding(NSUTF8StringEncoding)!.SHA256() // AES-256
let IV = try! NSData.random(16) // Randomly generated IV. Length is equal to the AES block size(128)
let plaintext = "plain text".data(using: String.Encoding.utf8)!
let sharedSecretKey = "shared_secret_key".data(using: String.Encoding.utf8)!.SHA256() // AES-256
let IV = try! Data.random(16) // Randomly generated IV. Length is equal to the AES block size(128)
let ciphertext = try! plaintext.encrypt(.AES, options: .PKCS7Padding, key: sharedSecretKey, iv: IV)
let plaintext2 = try! ciphertext.decrypt(.AES, options: .PKCS7Padding, key: sharedSecretKey, iv: IV)
```
Expand All @@ -150,8 +149,8 @@ let plaintext2 = try! ciphertext.decrypt(.AES, options: .PKCS7Padding, key: shar
Key derivation functions are used for turning a passphrase into an arbitrary length key for use as a cryptographic key in subsequent operations.

```swift
let password = "password".dataUsingEncoding(NSUTF8StringEncoding)!
let salt = try! NSData.random(32)
let password = "password".data(using: String.Encoding.utf8)!
let salt = try! Data.random(32)
let derivedKey = try! password.derivedKey(salt, pseudoRandomAlgorithm: .SHA256, rounds: 20, derivedKeyLength: 32)
```

Expand Down
4 changes: 2 additions & 2 deletions SCrypto.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -535,7 +535,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
Expand Down
14 changes: 7 additions & 7 deletions Source/SCrypto.swift
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public extension MessageDigestProducible {
}
}

/// The `NSData` extension defines methods to compute the message digest.
/// The `Data` extension defines methods to compute the message digest.
extension Data: MessageDigestProducible {

/**
Expand Down Expand Up @@ -316,16 +316,16 @@ public final class Random {
}
}

/// The NSData extension defines a method for random bytes generation.
/// The Data extension defines a method for random bytes generation.
public extension Data {

/**
Creates NSData object of the specified length and populates it with randomly generated bytes.
Creates Data object of the specified length and populates it with randomly generated bytes.
The created object has cryptographically strong random bits suitable for use as cryptographic keys, IVs, nonces etc.

- parameter length: Number of random bytes to return.

- returns: newly created NSData object populated with randomly generated bytes.
- returns: newly created Data object populated with randomly generated bytes.
*/
public static func random(_ length : Int) throws -> Data {
let bytes = try Random.generateBytes(length)
Expand Down Expand Up @@ -418,7 +418,7 @@ public final class HMAC {

}

/// The NSData extension defines methods to compute the HMAC.
/// The Data extension defines methods to compute the HMAC.
public extension Data {

/**
Expand Down Expand Up @@ -610,7 +610,7 @@ public final class Cipher {

}

/// The NSData extension defines methods for symmetric encryption algorithms.
/// The Data extension defines methods for symmetric encryption algorithms.
public extension Data {

/**
Expand Down Expand Up @@ -727,7 +727,7 @@ public final class PBKDF {
}


/// The NSData extension defines methods for deriving a key from a text password/passphrase.
/// The Data extension defines methods for deriving a key from a text password/passphrase.
public extension Data {

/**
Expand Down

0 comments on commit f0dd55c

Please sign in to comment.