# < Summary

Information

Class: | Renci.SshNet.Security.Cryptography.Ciphers.Paddings.PKCS7Padding
Assembly: | Renci.SshNet
File(s): | \home\appveyor\projects\ssh-net\src\Renci.SshNet\Security\Cryptography\Ciphers\Paddings\PKCS7Padding.cs

Line coverage
100%

Covered lines: | 13
Uncovered lines: | 0
Coverable lines: | 13
Total lines: | 49
Line coverage: | 100%

Branch coverage
100%

Covered branches: | 2
Total branches: | 2
Branch coverage: | 100%

Method coverage

Feature is only available for sponsors

Upgrade to PRO version

# Metrics

Method | Branch coverage | Cyclomatic complexity | Line coverage
--- | --- | --- | ---
Pad(...) | 100% | 1 | 100%
Pad(...) | 100% | 2 | 100%

# File(s)

## \home\appveyor\projects\ssh-net\src\Renci.SshNet\Security\Cryptography\Ciphers\Paddings\PKCS7Padding.cs

| # | Line |  | Line coverage
--- | --- | --- | --- | ---
|  | `1` |  | `using System;`
|  | `2` |  | ``
|  | `3` |  | `namespace Renci.SshNet.Security.Cryptography.Ciphers.Paddings`
|  | `4` |  | `{`
|  | `5` |  | `/// <summary>`
|  | `6` |  | `/// Implements PKCS7 cipher padding.`
|  | `7` |  | `/// </summary>`
|  | `8` |  | `public class PKCS7Padding : CipherPadding`
|  | `9` |  | `{`
|  | `10` |  | `/// <summary>`
|  | `11` |  | `/// Pads the specified input to match the block size.`
|  | `12` |  | `/// </summary>`
|  | `13` |  | `/// <param name="blockSize">The size of the block.</param>`
|  | `14` |  | `/// <param name="input">The input.</param>`
|  | `15` |  | `/// <param name="offset">The zero-based offset in <paramref name="input"/> at which the data to pad starts.</par`
|  | `16` |  | `/// <param name="length">The number of bytes in <paramref name="input"/> to take into account.</param>`
|  | `17` |  | `/// <returns>`
|  | `18` |  | `/// The padded data array.`
|  | `19` |  | `/// </returns>`
|  | `20` |  | `public override byte[] Pad(int blockSize, byte[] input, int offset, int length)`
| 15 | `21` |  | `{`
| 15 | `22` |  | `var numOfPaddedBytes = blockSize - (length % blockSize);`
| 15 | `23` |  | `return Pad(input, offset, length, numOfPaddedBytes);`
| 15 | `24` |  | `}`
|  | `25` |  | ``
|  | `26` |  | `/// <summary>`
|  | `27` |  | `/// Pads the specified input with a given number of bytes.`
|  | `28` |  | `/// </summary>`
|  | `29` |  | `/// <param name="input">The input.</param>`
|  | `30` |  | `/// <param name="offset">The zero-based offset in <paramref name="input"/> at which the data to pad starts.</par`
|  | `31` |  | `/// <param name="length">The number of bytes in <paramref name="input"/> to take into account.</param>`
|  | `32` |  | `/// <param name="paddinglength">The number of bytes to pad the input with.</param>`
|  | `33` |  | `/// <returns>`
|  | `34` |  | `/// The padded data array.`
|  | `35` |  | `/// </returns>`
|  | `36` |  | `public override byte[] Pad(byte[] input, int offset, int length, int paddinglength)`
| 15 | `37` |  | `{`
| 15 | `38` |  | `var output = new byte[length + paddinglength];`
| 15 | `39` |  | `Buffer.BlockCopy(input, offset, output, 0, length);`
|  | `40` |  | ``
| 162 | `41` |  | `for (var i = 0; i < paddinglength; i++)`
| 66 | `42` |  | `{`
| 66 | `43` |  | `output[length + i] = (byte) paddinglength;`
| 66 | `44` |  | `}`
|  | `45` |  | ``
| 15 | `46` |  | `return output;`
| 15 | `47` |  | `}`
|  | `48` |  | `}`
|  | `49` |  | `}`

# Methods/Properties

Pad(System.Int32,System.Byte[],System.Int32,System.Int32)
Pad(System.Byte[],System.Int32,System.Int32,System.Int32)