Using paddings - ivan-zaera/cipher GitHub Wiki
To use a Padding you can use the following code:
var padding = new Padding( "PKCS7" );
var data = inputPlainText();
var paddedData = padding.process( data );
outputPaddedData( paddedData );
In general, you construct the Padding with the factory constructor which receives the standard algorithm name. See
Algorithm nomenclature for documentation on standard algorithm names.
To pad data you call process() which returns a buffer with the passed in data plus the padding. Alternatively, if you want
more performance, you can call addPadding() which pads the data in the same buffer it is passed. Keep in mind that the
'process()andaddPadding()` methods assume that the last block of plain text is always passed to them inside [data]. The
reason for this is that some modes such as "trailing bit compliment" base the padding on the last byte of plain text.
You can reset the digest to its initial state with the reset() method.