PKCS7Padding
Implements PKCS7 cipher padding
using System;
namespace Renci.SshNet.Security.Cryptography.Ciphers.Paddings
{
public class PKCS7Padding : CipherPadding
{
public override byte[] Pad(int blockSize, byte[] input)
{
int length = blockSize - input.Length % blockSize;
return Pad(input, length);
}
public override byte[] Pad(byte[] input, int length)
{
byte[] array = new byte[input.Length + length];
Buffer.BlockCopy(input, 0, array, 0, input.Length);
for (int i = 0; i < length; i++) {
array[input.Length + i] = (byte)length;
}
return array;
}
}
}