Closed dollykosmos closed 5 years ago
By now, this library does not support PKCS#5 padding.
You can try this lines from CryptoSwift
func remove(from bytes: Array<UInt8>, blockSize _: Int?) -> Array<UInt8> {
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
if finalLength < 0 {
return bytes
}
if padding >= 1 {
return Array(bytes[0..<finalLength])
}
return bytes
}
Thanks for the update. I am using CryptoSwift only for now. My issue resolved.
How to remove PKCS#5 padding in last from decrypted string