         XCTAssertEqual(derivedKey.hexString(), expectedDerivedKey)
     }
 
+    private func calibrate(password: String, saltLength: Int, pseudoRandomAlgorithm: PBKDF.PseudoRandomAlgorithm, derivedKeyLength: Int, msec: UInt32) {
+        let password = password.dataUsingEncoding(NSUTF8StringEncoding)!
+        let iterations = password.calibrate(saltLength, pseudoRandomAlgorithm: pseudoRandomAlgorithm, derivedKeyLength: derivedKeyLength, msec: msec)
+        XCTAssertTrue(iterations > 0)
+    }
+
     // MARK: Cryptor
 
     func testAES_CBC_128() {

        static let aesCiphertext_CBC_256_IV = "O49HzhxdRYMgzqQYx+pECj98Mxn+EtFy7ZnBE9yr+fPZXwgzWaLnLasoKszifIlHRnY3W0ehdWT2Zysaguorcw=="
    }

    // MARK: Digest

    func testMD2() {
        digest(Consts.message, expectedDigest: Consts.MD2) { $0.MD2() }
    }

    func testMD4() {
        digest(Consts.message, expectedDigest: Consts.MD4) { $0.MD4() }
    }

    func testMD5() {
        digest(Consts.message, expectedDigest: Consts.MD5) { $0.MD5() }
    }

    func testSHA224() {
        digest(Consts.message, expectedDigest: Consts.SHA224) { $0.SHA224() }
    }

    func testSHA256() {
        digest(Consts.message, expectedDigest: Consts.SHA256) { $0.SHA256() }
    }

    func testSHA384() {
        digest(Consts.message, expectedDigest: Consts.SHA384) { $0.SHA384() }
    }

    func testSHA512() {
        digest(Consts.message, expectedDigest: Consts.SHA512) { $0.SHA512() }
    }

    private func digest(message: String, expectedDigest: String, algorithm: (NSData) -> NSData) {
        let message = message.dataUsingEncoding(NSUTF8StringEncoding)!
        let digest = algorithm(message).hexString()
        XCTAssertEqual(digest, expectedDigest)
    }


        let aesKey = NSData(base64EncodedString: key, options: [])!
        let IV = IV == nil ? nil : NSData(base64EncodedString: IV!, options: [])
        let ciphertext = try! plaintext.encrypt(algorithm, options: options, key: aesKey, iv: IV)
        let plaintextProof = try! ciphertext.decrypt(algorithm, options: options, key: aesKey, iv: IV)
        XCTAssertEqual(plaintext, plaintextProof)
        XCTAssertEqual(ciphertext.base64EncodedStringWithOptions([]), expectedCyphertext)
    }

