Documentation ¶
Overview ¶
This package implements PKCS#7 padding to byte slices. Padding works by calculating the amount of needed padding and repeating that number to fill in the rest of the slice up to the block size. This way, in order to unpad the slice, you check the value held in the last slot and then remove that many bytes from the end.
By defniition, PKCS#7 only padds for block sizes between 1 and 255 inclusive. If the supplied byte slice is a multiple of the block size, N, an extra N amount of bytes is appended all of value N.
Please review the tests for this package for examples.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Pkcs5Padding ¶ added in v1.0.25
func Pkcs5Unpadding ¶ added in v1.0.25
func Pkcs7Padding ¶ added in v1.0.24
Pad takes a source byte slice and a block size. It will determine the needed amount of padding, n, and appends byte(n) to the source n times.
Example Input: Block Size 8, Source {0xDE, 0xAD, 0xBE, 0xEF}
Expected Output: {0xDE, 0xAD, 0xBE, 0xEF, 0x04, 0x04, 0x04, 0x04}
func Pkcs7Unpadding ¶ added in v1.0.24
Unpad takes a source byte slice and will remove any padding added according to PKCS#7 specifications. An error is returned for invalid padding.
Types ¶
This section is empty.