Browse Source

Minor change to Cryptor.finish interface: finish(withBytes:)

Marcin Krzyżanowski 9 years ago
parent
commit
123d8fe5b6
2 changed files with 5 additions and 5 deletions
  1. 3 3
      CryptoSwiftTests/AESTests.swift
  2. 2 2
      Sources/CryptoSwift/Cryptor.swift

+ 3 - 3
CryptoSwiftTests/AESTests.swift

@@ -86,9 +86,9 @@ final class AESTests: XCTestCase {
 
         var partialEncrypted = [UInt8]()
         var encryptor = aes.makeEncryptor()
-        partialEncrypted.appendContentsOf(try! encryptor.updateWith(bytes: Array(plaintext[0..<16]), isLast: false))
-        //partialEncrypted.appendContentsOf(try! encryptor.finish(bytes: Array(plaintext[16..<32])))
-        partialEncrypted.appendContentsOf(try! encryptor.updateWith(bytes: Array(plaintext[16..<32]), isLast: true))
+        partialEncrypted.appendContentsOf(try! encryptor.updateWith(bytes: Array(plaintext[0..<16])))
+        partialEncrypted.appendContentsOf(try! encryptor.finish(withBytes: Array(plaintext[16..<32])))
+        //partialEncrypted.appendContentsOf(try! encryptor.finish())
         XCTAssertEqual(encrypted, partialEncrypted, "encryption failed")
     }
 

+ 2 - 2
Sources/CryptoSwift/Cryptor.swift

@@ -13,11 +13,11 @@ public protocol Cryptor {
     /// - parameter isLast: Given chunk is the last one. No more updates after this call.
     /// - returns: Plaintext data
     mutating func updateWith(bytes bytes:[UInt8], isLast: Bool) throws -> [UInt8]
-    mutating func finish(bytes bytes:[UInt8]) throws  -> [UInt8]
+    mutating func finish(withBytes bytes:[UInt8]) throws  -> [UInt8]
 }
 
 extension Cryptor {
-    mutating public func finish(bytes bytes:[UInt8] = []) throws  -> [UInt8] {
+    mutating public func finish(withBytes bytes:[UInt8] = []) throws  -> [UInt8] {
         return try self.updateWith(bytes: bytes, isLast: true)
     }
 }