Renci.SshNet.Security.Cryptography.Ciphers.Paddings.PKCS5Padding.Pad C# (CSharp) Method

Pad() public method

Pads the specified input with a given number of bytes.
public Pad ( byte input, int offset, int length, int paddinglength ) : byte[]
input byte The input.
offset int The zero-based offset in at which the data to pad starts.
length int The number of bytes in to take into account.
paddinglength int The number of bytes to pad the input with.
return byte[]
        public override byte[] Pad(byte[] input, int offset, int length, int paddinglength)
        {
            var output = new byte[length + paddinglength];
            Buffer.BlockCopy(input, offset, output, 0, length);
            for (var i = 0; i < paddinglength; i++)
            {
                output[length + i] = (byte) paddinglength;
            }
            return output;
        }
    }

Same methods

PKCS5Padding::Pad ( int blockSize, byte input, int offset, int length ) : byte[]

Usage Example

Example #1
0
 [Ignore] // placeholder for actual test
 public void PadTest()
 {
     PKCS5Padding target = new PKCS5Padding(); // TODO: Initialize to an appropriate value
     int blockSize = 0; // TODO: Initialize to an appropriate value
     byte[] input = null; // TODO: Initialize to an appropriate value
     byte[] expected = null; // TODO: Initialize to an appropriate value
     byte[] actual;
     actual = target.Pad(blockSize, input);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
PKCS5Padding