Archived Forum Post

Index of archived forum posts

Question:

zero padding

Oct 03 '12 at 13:19

I am trying to use Chilkat Encryption Library in iOS. I am using 3DES in CBC mode. Is it possible to encrypt with 'zero padding' ilke in .NET?


Answer

See the online reference documentation for PaddingScheme. Here it is reproduced:

Possible values are:

0 = RFC 1423 padding scheme: Each padding byte is set to the number of padding bytes. If the data is already a multiple of algorithm's block size bytes, an extra block is appended each having a value equal to the block size. (for example, if the algorithm's block size is 16, then 16 bytes having the value 0x10 are added.). (This is also known as PKCS5 padding: PKCS #5 padding string consists of a sequence of bytes, each of which is equal to the total number of padding bytes added. )

1 = FIPS81 (Federal Information Processing Standards 81) where the last byte contains the number of padding bytes, including itself, and the other padding bytes are set to random values.

2 = Each padding byte is set to a random value. The decryptor must know how many bytes are in the original unencrypted data.

3 = Pad with NULLs. (If already a multiple of the algorithm's block size, no padding is added).

4 = Pad with SPACE chars(0x20). (If already a multiple of algorithm's block size, no padding is added).


Answer

Got it...!!! I had to use '3' for implementing zero padding. Thank you so much....!!!