Weizhi
Weizhi

Reputation: 172

How to implement AES PKCS5Padding using Objective-c

I found that there is no PKCS5Padding padding on iOS. How can I implement an AES encryption using PKCS5Padding?

Upvotes: 2

Views: 1284

Answers (1)

Codo
Codo

Reputation: 78795

AES always has a block size of 16 bytes. PKCS #5 padding is only defined for 8 byte blocks. So this combination is invalid. I don't know where your got that requirement from.

However, PKCS #7 padding is the same padding mechanism but it's defined for different block sizes. PKCS #7 for 8 byte blocks is the same as PKCS #5.

So most likely you want to use PKCS #7, which is available on iOS.

Upvotes: 2

Related Questions