@@ -12,44 +12,52 @@ public protocol UpdatableCryptor {
1212 /// - parameter bytes: Bytes to process
1313 /// - parameter isLast: (Optional) Given chunk is the last one. No more updates after this call.
1414 /// - returns: Processed data or empty array.
15- mutating func update( withBytes bytes: Array < UInt8 > , isLast: Bool ) throws -> Array < UInt8 >
15+ mutating func update< T : SequenceType where T . Generator . Element == UInt8 > ( withBytes bytes: T , isLast: Bool ) throws -> Array < UInt8 >
1616
1717 /// Encrypt/Decrypt given bytes in chunks.
1818 ///
1919 /// - parameter bytes: Bytes to process
2020 /// - parameter isLast: (Optional) Given chunk is the last one. No more updates after this call.
2121 /// - parameter output: Resulting data
2222 /// - returns: Processed data or empty array.
23- mutating func update( withBytes bytes: Array < UInt8 > , isLast: Bool , output: ( Array < UInt8 > ) -> Void ) throws
23+ mutating func update< T : SequenceType where T . Generator . Element == UInt8 > ( withBytes bytes: T , isLast: Bool , output: ( Array < UInt8 > ) -> Void ) throws
2424
2525 /// Finish encryption/decryption. This may apply padding.
2626 /// - parameter bytes: Bytes to process
2727 /// - returns: Processed data.
28- mutating func finish( withBytes bytes: Array < UInt8 > ) throws -> Array < UInt8 >
28+ mutating func finish< T : SequenceType where T . Generator . Element == UInt8 > ( withBytes bytes: T ) throws -> Array < UInt8 >
2929
3030 /// Finish encryption/decryption. This may apply padding.
3131 /// - parameter bytes: Bytes to process
3232 /// - parameter output: Resulting data
3333 /// - returns: Processed data.
34- mutating func finish( withBytes bytes: Array < UInt8 > , output: ( Array < UInt8 > ) -> Void ) throws
34+ mutating func finish< T : SequenceType where T . Generator . Element == UInt8 > ( withBytes bytes: T , output: ( Array < UInt8 > ) -> Void ) throws
3535}
3636
3737extension UpdatableCryptor {
38- mutating public func update( withBytes bytes: Array < UInt8 > , isLast: Bool = false , output: ( Array < UInt8 > ) -> Void ) throws {
38+ mutating public func update< T : SequenceType where T . Generator . Element == UInt8 > ( withBytes bytes: T , isLast: Bool = false , output: ( Array < UInt8 > ) -> Void ) throws {
3939 let processed = try self . update ( withBytes: bytes, isLast: isLast)
4040 if ( !processed. isEmpty) {
4141 output ( processed)
4242 }
4343 }
4444
45- mutating public func finish( withBytes bytes: Array < UInt8 > = [ ] ) throws -> Array < UInt8 > {
45+ mutating public func finish< T : SequenceType where T . Generator . Element == UInt8 > ( withBytes bytes: T ) throws -> Array < UInt8 > {
4646 return try self . update ( withBytes: bytes, isLast: true )
4747 }
48+
49+ mutating public func finish( ) throws -> Array < UInt8 > {
50+ return try self . update ( withBytes: [ ] , isLast: true )
51+ }
4852
49- mutating public func finish( withBytes bytes: Array < UInt8 > = [ ] , output: ( Array < UInt8 > ) -> Void ) throws {
53+ mutating public func finish< T : SequenceType where T . Generator . Element == UInt8 > ( withBytes bytes: T , output: ( Array < UInt8 > ) -> Void ) throws {
5054 let processed = try self . update ( withBytes: bytes, isLast: true )
5155 if ( !processed. isEmpty) {
5256 output ( processed)
5357 }
5458 }
59+
60+ mutating public func finish( output: ( Array < UInt8 > ) -> Void ) throws {
61+ try self . finish ( withBytes: [ ] , output: output)
62+ }
5563}
0 commit comments