Ver código fonte

Fixes invalid result value on device. Fixes #57

Marcin Krzyżanowski 10 anos atrás
pai
commit
f146411a7c
1 arquivos alterados com 2 adições e 1 exclusões
  1. 2 1
      CryptoSwift/PKCS7.swift

+ 2 - 1
CryptoSwift/PKCS7.swift

@@ -35,7 +35,8 @@ public struct PKCS7: Padding {
     }
     }
     
     
     public func remove(bytes: [UInt8], blockSize:Int? = nil) -> [UInt8] {
     public func remove(bytes: [UInt8], blockSize:Int? = nil) -> [UInt8] {
-        var padding = Int(bytes.last!) // last byte
+        let lastByte = bytes.last!
+        var padding = Int(lastByte) // last byte
         
         
         if padding >= 1 { //TODO: need test for that, what about empty padding
         if padding >= 1 { //TODO: need test for that, what about empty padding
             return Array(bytes[0..<(bytes.count - padding)])
             return Array(bytes[0..<(bytes.count - padding)])