Эх сурвалжийг харах

Remove Generics 😅😢😪

Marcin Krzyżanowski 8 жил өмнө
parent
commit
d30e986b50

+ 4 - 4
Sources/CryptoSwift/AES.swift

@@ -449,7 +449,7 @@ extension AES {
             self.paddingRequired = aes.blockMode.options.contains(.PaddingRequired)
             self.paddingRequired = aes.blockMode.options.contains(.PaddingRequired)
         }
         }
 
 
-        mutating public func update<T: Collection>(withBytes bytes: T, isLast: Bool = false) throws -> Array<UInt8> where T.Iterator.Element == UInt8 {
+        mutating public func update(withBytes bytes: ArraySlice<UInt8>, isLast: Bool = false) throws -> Array<UInt8> {
             self.accumulated += bytes
             self.accumulated += bytes
 
 
             if isLast {
             if isLast {
@@ -499,7 +499,7 @@ extension AES {
             self.paddingRequired = aes.blockMode.options.contains(.PaddingRequired)
             self.paddingRequired = aes.blockMode.options.contains(.PaddingRequired)
         }
         }
 
 
-        mutating public func update<T: Collection>(withBytes bytes: T, isLast: Bool = false) throws -> Array<UInt8> where T.Iterator.Element == UInt8 {
+        mutating public func update(withBytes bytes: ArraySlice<UInt8>, isLast: Bool = false) throws -> Array<UInt8> {
             // prepend "offset" number of bytes at the begining
             // prepend "offset" number of bytes at the begining
             if self.offset > 0 {
             if self.offset > 0 {
                 self.accumulated += Array<UInt8>(repeating: 0, count: offset) + bytes
                 self.accumulated += Array<UInt8>(repeating: 0, count: offset) + bytes
@@ -567,7 +567,7 @@ extension AES: Cryptors {
 // MARK: Cipher
 // MARK: Cipher
 extension AES: Cipher {
 extension AES: Cipher {
 
 
-    public func encrypt<C: Collection>(_ bytes: C) throws -> Array<UInt8> where C.Element == UInt8, C.IndexDistance == Int, C.Index == Int, C.SubSequence: Collection {
+    public func encrypt(_ bytes: ArraySlice<UInt8>) throws -> Array<UInt8> {
         let chunks = bytes.batched(by: AES.blockSize)
         let chunks = bytes.batched(by: AES.blockSize)
 
 
         var oneTimeCryptor = self.makeEncryptor()
         var oneTimeCryptor = self.makeEncryptor()
@@ -586,7 +586,7 @@ extension AES: Cipher {
         return out
         return out
     }
     }
 
 
-    public func decrypt<C: Collection>(_ bytes: C) throws -> Array<UInt8> where C.Element == UInt8, C.IndexDistance == Int, C.Index == Int, C.SubSequence: Collection {
+    public func decrypt(_ bytes: ArraySlice<UInt8>) throws -> Array<UInt8> {
         if blockMode.options.contains(.PaddingRequired) && (bytes.count % AES.blockSize != 0) {
         if blockMode.options.contains(.PaddingRequired) && (bytes.count % AES.blockSize != 0) {
             throw Error.dataPaddingRequired
             throw Error.dataPaddingRequired
         }
         }

+ 4 - 0
Sources/CryptoSwift/Array+Extension.swift

@@ -19,6 +19,10 @@ extension Array {
         self = Array<Element>()
         self = Array<Element>()
         self.reserveCapacity(reserveCapacity)
         self.reserveCapacity(reserveCapacity)
     }
     }
+
+    var slice: ArraySlice<Element> {
+        return self[self.startIndex..<self.endIndex]
+    }
 }
 }
 
 
 extension Array {
 extension Array {

+ 2 - 2
Sources/CryptoSwift/CSArrayType+Extensions.swift

@@ -81,11 +81,11 @@ public extension CSArrayType where Iterator.Element == UInt8 {
     }
     }
 
 
     public func encrypt(cipher: Cipher) throws -> [Iterator.Element] {
     public func encrypt(cipher: Cipher) throws -> [Iterator.Element] {
-        return try cipher.encrypt(cs_arrayValue())
+        return try cipher.encrypt(cs_arrayValue().slice)
     }
     }
 
 
     public func decrypt(cipher: Cipher) throws -> [Iterator.Element] {
     public func decrypt(cipher: Cipher) throws -> [Iterator.Element] {
-        return try cipher.decrypt(cs_arrayValue())
+        return try cipher.decrypt(cs_arrayValue().slice)
     }
     }
 
 
     public func authenticate<A: Authenticator>(with authenticator: A) throws -> [Iterator.Element] {
     public func authenticate<A: Authenticator>(with authenticator: A) throws -> [Iterator.Element] {

+ 2 - 2
Sources/CryptoSwift/ChaCha20.swift

@@ -264,7 +264,7 @@ extension ChaCha20 {
             self.chacha = chacha
             self.chacha = chacha
         }
         }
 
 
-        mutating public func update<T: Collection>(withBytes bytes: T, isLast: Bool = false) throws -> Array<UInt8> where T.Iterator.Element == UInt8 {
+        mutating public func update(withBytes bytes: ArraySlice<UInt8>, isLast: Bool = false) throws -> Array<UInt8> {
             self.accumulated += bytes
             self.accumulated += bytes
 
 
             var encrypted = Array<UInt8>()
             var encrypted = Array<UInt8>()
@@ -294,7 +294,7 @@ extension ChaCha20 {
             self.chacha = chacha
             self.chacha = chacha
         }
         }
 
 
-        mutating public func update<T: Collection>(withBytes bytes: T, isLast: Bool = true) throws -> Array<UInt8> where T.Iterator.Element == UInt8 {
+        mutating public func update(withBytes bytes: ArraySlice<UInt8>, isLast: Bool = true) throws -> Array<UInt8> {
             // prepend "offset" number of bytes at the begining
             // prepend "offset" number of bytes at the begining
             if self.offset > 0 {
             if self.offset > 0 {
                 self.accumulated += Array<UInt8>(repeating: 0, count: offset) + bytes
                 self.accumulated += Array<UInt8>(repeating: 0, count: offset) + bytes

+ 2 - 2
Sources/CryptoSwift/Cipher.swift

@@ -24,11 +24,11 @@ public protocol Cipher: class {
     ///
     ///
     /// - parameter bytes: Plaintext data
     /// - parameter bytes: Plaintext data
     /// - returns: Encrypted data
     /// - returns: Encrypted data
-    func encrypt<C: Collection>(_ bytes: C) throws -> Array<UInt8> where C.Element == UInt8, C.IndexDistance == Int, C.Index == Int, C.SubSequence: Collection, C.SubSequence.IndexDistance == C.IndexDistance
+    func encrypt(_ bytes: ArraySlice<UInt8>) throws -> Array<UInt8>
 
 
     /// Decrypt given bytes at once
     /// Decrypt given bytes at once
     ///
     ///
     /// - parameter bytes: Ciphertext data
     /// - parameter bytes: Ciphertext data
     /// - returns: Plaintext data
     /// - returns: Plaintext data
-    func decrypt<C: Collection>(_ bytes: C) throws -> Array<UInt8> where C.Element == UInt8, C.IndexDistance == Int, C.Index == Int, C.SubSequence: Collection, C.SubSequence.IndexDistance == C.IndexDistance
+    func decrypt(_ bytes: ArraySlice<UInt8>) throws -> Array<UInt8>
 }
 }

+ 2 - 2
Sources/CryptoSwift/Foundation/Data+Extension.swift

@@ -66,11 +66,11 @@ extension Data {
     }
     }
 
 
     public func encrypt(cipher: Cipher) throws -> Data {
     public func encrypt(cipher: Cipher) throws -> Data {
-        return Data(bytes: try cipher.encrypt(self.bytes))
+        return Data(bytes: try cipher.encrypt(self.bytes.slice))
     }
     }
 
 
     public func decrypt(cipher: Cipher) throws -> Data {
     public func decrypt(cipher: Cipher) throws -> Data {
-        return Data(bytes: try cipher.decrypt(self.bytes))
+        return Data(bytes: try cipher.decrypt(self.bytes.slice))
     }
     }
 
 
     public func authenticate(with authenticator: Authenticator) throws -> Data {
     public func authenticate(with authenticator: Authenticator) throws -> Data {

+ 7 - 5
Sources/CryptoSwift/Generics.swift

@@ -15,7 +15,7 @@
 //
 //
 
 
 /** build bit pattern from array of bits */
 /** build bit pattern from array of bits */
-@_specialize(where T == UInt8)
+@_specialize(exported: true, where T == UInt8)
 func integerFrom<T: FixedWidthInteger>(_ bits: Array<Bit>) -> T {
 func integerFrom<T: FixedWidthInteger>(_ bits: Array<Bit>) -> T {
     var bitPattern: T = 0
     var bitPattern: T = 0
     for idx in bits.indices {
     for idx in bits.indices {
@@ -33,10 +33,12 @@ func integerFrom<T: FixedWidthInteger>(_ bits: Array<Bit>) -> T {
 /// - parameter length: length of output array. By default size of value type
 /// - parameter length: length of output array. By default size of value type
 ///
 ///
 /// - returns: Array of bytes
 /// - returns: Array of bytes
-@_specialize(where T == Int)
-@_specialize(where T == UInt16)
-@_specialize(where T == UInt32)
-@_specialize(where T == UInt64)
+@_specialize(exported: true, where T == Int)
+@_specialize(exported: true, where T == UInt)
+@_specialize(exported: true, where T == UInt8)
+@_specialize(exported: true, where T == UInt16)
+@_specialize(exported: true, where T == UInt32)
+@_specialize(exported: true, where T == UInt64)
 func arrayOfBytes<T: FixedWidthInteger>(value: T, length totalBytes: Int = MemoryLayout<T>.size) -> Array<UInt8> {
 func arrayOfBytes<T: FixedWidthInteger>(value: T, length totalBytes: Int = MemoryLayout<T>.size) -> Array<UInt8> {
     let valuePointer = UnsafeMutablePointer<T>.allocate(capacity: 1)
     let valuePointer = UnsafeMutablePointer<T>.allocate(capacity: 1)
     valuePointer.pointee = value
     valuePointer.pointee = value

+ 0 - 5
Sources/CryptoSwift/Int+Extension.swift

@@ -32,11 +32,6 @@ extension Int {
 /* array of bytes */
 /* array of bytes */
 extension Int {
 extension Int {
 
 
-    /** Int with collection of bytes (little-endian) */
-    // init<T: Collection>(bytes: T) where T.Iterator.Element == UInt8, T.Index == Int {
-    //    self = bytes.toInteger()
-    // }
-
     /** Array of bytes with optional padding */
     /** Array of bytes with optional padding */
     func bytes(totalBytes: Int = MemoryLayout<Int>.size) -> Array<UInt8> {
     func bytes(totalBytes: Int = MemoryLayout<Int>.size) -> Array<UInt8> {
         return arrayOfBytes(value: self, length: totalBytes)
         return arrayOfBytes(value: self, length: totalBytes)

+ 2 - 2
Sources/CryptoSwift/MD5.swift

@@ -52,7 +52,7 @@ public final class MD5: DigestType {
 
 
     public func calculate(for bytes: Array<UInt8>) -> Array<UInt8> {
     public func calculate(for bytes: Array<UInt8>) -> Array<UInt8> {
         do {
         do {
-            return try self.update(withBytes: bytes, isLast: true)
+            return try self.update(withBytes: bytes.slice, isLast: true)
         } catch {
         } catch {
             fatalError()
             fatalError()
         }
         }
@@ -120,7 +120,7 @@ public final class MD5: DigestType {
 
 
 extension MD5: Updatable {
 extension MD5: Updatable {
 
 
-    public func update<T: Collection>(withBytes bytes: T, isLast: Bool = false) throws -> Array<UInt8> where T.Iterator.Element == UInt8 {
+    public func update(withBytes bytes: ArraySlice<UInt8>, isLast: Bool = false) throws -> Array<UInt8> {
         self.accumulated += bytes
         self.accumulated += bytes
 
 
         if isLast {
         if isLast {

+ 2 - 2
Sources/CryptoSwift/SHA1.swift

@@ -28,7 +28,7 @@ public final class SHA1: DigestType {
 
 
     public func calculate(for bytes: Array<UInt8>) -> Array<UInt8> {
     public func calculate(for bytes: Array<UInt8>) -> Array<UInt8> {
         do {
         do {
-            return try self.update(withBytes: bytes, isLast: true)
+            return try self.update(withBytes: bytes.slice, isLast: true)
         } catch {
         } catch {
             return []
             return []
         }
         }
@@ -100,7 +100,7 @@ public final class SHA1: DigestType {
 
 
 extension SHA1: Updatable {
 extension SHA1: Updatable {
 
 
-    public func update<T: Collection>(withBytes bytes: T, isLast: Bool = false) throws -> Array<UInt8> where T.Iterator.Element == UInt8 {
+    public func update(withBytes bytes: ArraySlice<UInt8>, isLast: Bool = false) throws -> Array<UInt8> {
         self.accumulated += bytes
         self.accumulated += bytes
 
 
         if isLast {
         if isLast {

+ 2 - 2
Sources/CryptoSwift/SHA2.swift

@@ -145,7 +145,7 @@ public final class SHA2: DigestType {
 
 
     public func calculate(for bytes: Array<UInt8>) -> Array<UInt8> {
     public func calculate(for bytes: Array<UInt8>) -> Array<UInt8> {
         do {
         do {
-            return try self.update(withBytes: bytes, isLast: true)
+            return try self.update(withBytes: bytes.slice, isLast: true)
         } catch {
         } catch {
             return []
             return []
         }
         }
@@ -267,7 +267,7 @@ public final class SHA2: DigestType {
 
 
 extension SHA2: Updatable {
 extension SHA2: Updatable {
 
 
-    public func update<T: Collection>(withBytes bytes: T, isLast: Bool = false) throws -> Array<UInt8> where T.Iterator.Element == UInt8 {
+    public func update(withBytes bytes: ArraySlice<UInt8>, isLast: Bool = false) throws -> Array<UInt8> {
         self.accumulated += bytes
         self.accumulated += bytes
 
 
         if isLast {
         if isLast {

+ 4 - 4
Sources/CryptoSwift/SHA3.swift

@@ -92,7 +92,7 @@ public final class SHA3: DigestType {
 
 
     public func calculate(for bytes: Array<UInt8>) -> Array<UInt8> {
     public func calculate(for bytes: Array<UInt8>) -> Array<UInt8> {
         do {
         do {
-            return try self.update(withBytes: bytes, isLast: true)
+            return try self.update(withBytes: bytes.slice, isLast: true)
         } catch {
         } catch {
             return []
             return []
         }
         }
@@ -174,7 +174,7 @@ public final class SHA3: DigestType {
         a[0] ^= round_constants[round]
         a[0] ^= round_constants[round]
     }
     }
 
 
-    fileprivate func process<C: Collection>(block chunk: C, currentHash hh: inout Array<UInt64>) where C.Element == UInt64, C.Index == Int {
+    fileprivate func process(block chunk: ArraySlice<UInt64>, currentHash hh: inout Array<UInt64>) {
         // expand
         // expand
         hh[0] ^= chunk[0].littleEndian
         hh[0] ^= chunk[0].littleEndian
         hh[1] ^= chunk[1].littleEndian
         hh[1] ^= chunk[1].littleEndian
@@ -249,7 +249,7 @@ public final class SHA3: DigestType {
 
 
 extension SHA3: Updatable {
 extension SHA3: Updatable {
 
 
-    public func update<T: Collection>(withBytes bytes: T, isLast: Bool = false) throws -> Array<UInt8> where T.Iterator.Element == UInt8 {
+    public func update(withBytes bytes: ArraySlice<UInt8>, isLast: Bool = false) throws -> Array<UInt8> {
         self.accumulated += bytes
         self.accumulated += bytes
 
 
         if isLast {
         if isLast {
@@ -268,7 +268,7 @@ extension SHA3: Updatable {
         var processedBytes = 0
         var processedBytes = 0
         for chunk in self.accumulated.batched(by: self.blockSize) {
         for chunk in self.accumulated.batched(by: self.blockSize) {
             if (isLast || (self.accumulated.count - processedBytes) >= self.blockSize) {
             if (isLast || (self.accumulated.count - processedBytes) >= self.blockSize) {
-                self.process(block: chunk.toUInt64Array(), currentHash: &self.accumulatedHash)
+                self.process(block: chunk.toUInt64Array().slice, currentHash: &self.accumulatedHash)
                 processedBytes += chunk.count
                 processedBytes += chunk.count
             }
             }
         }
         }

+ 2 - 2
Sources/CryptoSwift/UInt16+Extension.swift

@@ -17,12 +17,12 @@
 /** array of bytes */
 /** array of bytes */
 extension UInt16 {
 extension UInt16 {
 
 
-    @_specialize(where T == ArraySlice<UInt8>)
+    @_specialize(exported: true, where T == ArraySlice<UInt8>)
     init<T: Collection>(bytes: T) where T.Iterator.Element == UInt8, T.Index == Int {
     init<T: Collection>(bytes: T) where T.Iterator.Element == UInt8, T.Index == Int {
         self = UInt16(bytes: bytes, fromIndex: bytes.startIndex)
         self = UInt16(bytes: bytes, fromIndex: bytes.startIndex)
     }
     }
 
 
-    @_specialize(where T == ArraySlice<UInt8>)
+    @_specialize(exported: true, where T == ArraySlice<UInt8>)
     init<T: Collection>(bytes: T, fromIndex index: T.Index) where T.Iterator.Element == UInt8, T.Index == Int {
     init<T: Collection>(bytes: T, fromIndex index: T.Index) where T.Iterator.Element == UInt8, T.Index == Int {
         let val0 = UInt16(bytes[index.advanced(by: 0)]) << 8
         let val0 = UInt16(bytes[index.advanced(by: 0)]) << 8
         let val1 = UInt16(bytes[index.advanced(by: 1)])
         let val1 = UInt16(bytes[index.advanced(by: 1)])

+ 2 - 2
Sources/CryptoSwift/UInt32+Extension.swift

@@ -26,12 +26,12 @@ extension UInt32: _UInt32Type {}
 /** array of bytes */
 /** array of bytes */
 extension UInt32 {
 extension UInt32 {
 
 
-    @_specialize(where T == ArraySlice<UInt8>)
+    @_specialize(exported: true, where T == ArraySlice<UInt8>)
     init<T: Collection>(bytes: T) where T.Iterator.Element == UInt8, T.Index == Int {
     init<T: Collection>(bytes: T) where T.Iterator.Element == UInt8, T.Index == Int {
         self = UInt32(bytes: bytes, fromIndex: bytes.startIndex)
         self = UInt32(bytes: bytes, fromIndex: bytes.startIndex)
     }
     }
 
 
-    @_specialize(where T == ArraySlice<UInt8>)
+    @_specialize(exported: true, where T == ArraySlice<UInt8>)
     init<T: Collection>(bytes: T, fromIndex index: T.Index) where T.Iterator.Element == UInt8, T.Index == Int {
     init<T: Collection>(bytes: T, fromIndex index: T.Index) where T.Iterator.Element == UInt8, T.Index == Int {
         let val0 = UInt32(bytes[index.advanced(by: 0)]) << 24
         let val0 = UInt32(bytes[index.advanced(by: 0)]) << 24
         let val1 = UInt32(bytes[index.advanced(by: 1)]) << 16
         let val1 = UInt32(bytes[index.advanced(by: 1)]) << 16

+ 2 - 6
Sources/CryptoSwift/UInt64+Extension.swift

@@ -17,16 +17,12 @@
 /** array of bytes */
 /** array of bytes */
 extension UInt64 {
 extension UInt64 {
 
 
-//    init<T: Collection>(bytes: T) where T.Iterator.Element == UInt8, T.Index == Int {
-//        self = 0
-//    }
-
-    @_specialize(where T == ArraySlice<UInt8>)
+    @_specialize(exported: true, where T == ArraySlice<UInt8>)
     init<T: Collection>(bytes: T) where T.Iterator.Element == UInt8, T.IndexDistance == Int, T.Index == Int {
     init<T: Collection>(bytes: T) where T.Iterator.Element == UInt8, T.IndexDistance == Int, T.Index == Int {
         self = UInt64(bytes: bytes, fromIndex: bytes.startIndex)
         self = UInt64(bytes: bytes, fromIndex: bytes.startIndex)
     }
     }
 
 
-    @_specialize(where T == ArraySlice<UInt8>)
+    @_specialize(exported: true, where T == ArraySlice<UInt8>)
     init<T: Collection>(bytes: T, fromIndex index: T.Index) where T.Iterator.Element == UInt8, T.IndexDistance == Int, T.Index == Int {
     init<T: Collection>(bytes: T, fromIndex index: T.Index) where T.Iterator.Element == UInt8, T.IndexDistance == Int, T.Index == Int {
         let val0 = UInt64(bytes[index.advanced(by: 0)]) << 56
         let val0 = UInt64(bytes[index.advanced(by: 0)]) << 56
         let val1 = UInt64(bytes[index.advanced(by: 1)]) << 48
         let val1 = UInt64(bytes[index.advanced(by: 1)]) << 48

+ 7 - 7
Sources/CryptoSwift/Updatable.swift

@@ -22,7 +22,7 @@ public protocol Updatable {
     /// - parameter bytes: Bytes to process.
     /// - parameter bytes: Bytes to process.
     /// - parameter isLast: Indicate if given chunk is the last one. No more updates after this call.
     /// - parameter isLast: Indicate if given chunk is the last one. No more updates after this call.
     /// - returns: Processed data or empty array.
     /// - returns: Processed data or empty array.
-    mutating func update<T: Collection>(withBytes bytes: T, isLast: Bool) throws -> Array<UInt8> where T.Iterator.Element == UInt8
+    mutating func update(withBytes bytes: ArraySlice<UInt8>, isLast: Bool) throws -> Array<UInt8>
 
 
     /// Update given bytes in chunks.
     /// Update given bytes in chunks.
     ///
     ///
@@ -31,30 +31,30 @@ public protocol Updatable {
     ///   - isLast: Indicate if given chunk is the last one. No more updates after this call.
     ///   - isLast: Indicate if given chunk is the last one. No more updates after this call.
     ///   - output: Resulting bytes callback.
     ///   - output: Resulting bytes callback.
     /// - Returns: Processed data or empty array.
     /// - Returns: Processed data or empty array.
-    mutating func update<T: Collection>(withBytes bytes: T, isLast: Bool, output: (_ bytes: Array<UInt8>) -> Void) throws where T.Iterator.Element == UInt8
+    mutating func update(withBytes bytes: ArraySlice<UInt8>, isLast: Bool, output: (_ bytes: Array<UInt8>) -> Void) throws
 
 
     /// Finish updates. This may apply padding.
     /// Finish updates. This may apply padding.
     /// - parameter bytes: Bytes to process
     /// - parameter bytes: Bytes to process
     /// - returns: Processed data.
     /// - returns: Processed data.
-    mutating func finish<T: Collection>(withBytes bytes: T) throws -> Array<UInt8> where T.Iterator.Element == UInt8
+    mutating func finish(withBytes bytes: ArraySlice<UInt8>) throws -> Array<UInt8>
 
 
     /// Finish updates. This may apply padding.
     /// Finish updates. This may apply padding.
     /// - parameter bytes: Bytes to process
     /// - parameter bytes: Bytes to process
     /// - parameter output: Resulting data
     /// - parameter output: Resulting data
     /// - returns: Processed data.
     /// - returns: Processed data.
-    mutating func finish<T: Collection>(withBytes bytes: T, output: (_ bytes: Array<UInt8>) -> Void) throws where T.Iterator.Element == UInt8
+    mutating func finish(withBytes bytes: ArraySlice<UInt8>, output: (_ bytes: Array<UInt8>) -> Void) throws
 }
 }
 
 
 extension Updatable {
 extension Updatable {
 
 
-    mutating public func update<T: Collection>(withBytes bytes: T, isLast: Bool = false, output: (_ bytes: Array<UInt8>) -> Void) throws where T.Iterator.Element == UInt8 {
+    mutating public func update(withBytes bytes: ArraySlice<UInt8>, isLast: Bool = false, output: (_ bytes: Array<UInt8>) -> Void) throws {
         let processed = try self.update(withBytes: bytes, isLast: isLast)
         let processed = try self.update(withBytes: bytes, isLast: isLast)
         if (!processed.isEmpty) {
         if (!processed.isEmpty) {
             output(processed)
             output(processed)
         }
         }
     }
     }
 
 
-    mutating public func finish<T: Collection>(withBytes bytes: T) throws -> Array<UInt8> where T.Iterator.Element == UInt8 {
+    mutating public func finish(withBytes bytes: ArraySlice<UInt8>) throws -> Array<UInt8> {
         return try self.update(withBytes: bytes, isLast: true)
         return try self.update(withBytes: bytes, isLast: true)
     }
     }
 
 
@@ -62,7 +62,7 @@ extension Updatable {
         return try self.update(withBytes: [], isLast: true)
         return try self.update(withBytes: [], isLast: true)
     }
     }
 
 
-    mutating public func finish<T: Collection>(withBytes bytes: T, output: (_ bytes: Array<UInt8>) -> Void) throws where T.Iterator.Element == UInt8 {
+    mutating public func finish(withBytes bytes: ArraySlice<UInt8>, output: (_ bytes: Array<UInt8>) -> Void) throws {
         let processed = try self.update(withBytes: bytes, isLast: true)
         let processed = try self.update(withBytes: bytes, isLast: true)
         if (!processed.isEmpty) {
         if (!processed.isEmpty) {
             output(processed)
             output(processed)