dcrypt.blockcipher.padding.pkcs7

Members

Structs

PKCS7Pad
struct PKCS7Pad

PKCS7Pad is an implementation of the PKCS7 block cipher padding scheme. A incomplete block will be padded with bytes like this:

Examples

test PKCS7 padding scheme on a 16 byte block

1 PKCS7Pad padding;
2 ubyte[16] block = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15];
3 
4 padding.addPadding(block, 15);
5 assert(block == [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,1], "PKCS7Padding failed");
6 assert(padding.padCount(block) == 1, "PKCS7Padding failed");
7 
8 padding.addPadding(block, 7);
9 assert(block == [0,1,2,3,4,5,6,9,9,9,9,9,9,9,9,9], "PKCS7Padding failed");
10 assert(padding.padCount(block) == 9, "PKCS7Padding failed");
11 
12 padding.addPadding(block, 0);
13 assert(block == [16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16], "PKCS7Padding failed");
14 assert(padding.padCount(block) == 16, "PKCS7Padding failed");

Meta