diff --git a/Sources/CryptoSwift/PKCS7.swift b/Sources/CryptoSwift/PKCS7.swift index d13a376..d53b754 100644 --- a/Sources/CryptoSwift/PKCS7.swift +++ b/Sources/CryptoSwift/PKCS7.swift @@ -37,11 +37,12 @@ public struct PKCS7: Padding { } public func remove(data bytes: Array, blockSize:Int?) -> Array { - assert(!bytes.isEmpty, "Need bytes to remove padding") guard !bytes.isEmpty, let lastByte = bytes.last else { return bytes } + assert(!bytes.isEmpty, "Need bytes to remove padding") + let padding = Int(lastByte) // last byte let finalLength = bytes.count - padding