PKCS5Paddingpublic final class PKCS5Padding extends Object implements PadderThis class implements padding as specified in the PKCS#5 standard. |
Fields Summary |
---|
private int | blockSizeContains the block size. |
Constructors Summary |
---|
public PKCS5Padding(int blockSize)Constructor.
this.blockSize = blockSize;
|
Methods Summary |
---|
public int | pad(byte[] queue, int count)Pads the input according to the PKCS5 padding scheme.
int len = blockSize - count;
for (int i = count; i < blockSize; i++) {
queue[i] = (byte) len;
}
return len;
| public int | unPad(byte[] outBuff, int size)Removes padding bytes that were added to the input.
int padValue = outBuff[size - 1] & 0xff;
if (padValue < 1 || padValue > blockSize) {
throw new BadPaddingException();
}
for (int i = 0; i < padValue; i++) {
if (outBuff[--size] != padValue)
throw new BadPaddingException();
}
return padValue;
|
|