Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func Pad ¶
Pad appends padding to the input buffer to make its length a multiple of the block size.
Parameters: - buffer: A byte slice representing the input data to be padded. - blockSize: An unsigned 8-bit integer specifying the block size for padding.
Returns: - A byte slice containing the padded data. - An error if the block size is less than 1 or greater than 255.
The function performs the following steps: 1. Checks if the block size is valid (between 1 and 255). If not, it returns an error. 2. Calculates the padding length required to make the buffer length a multiple of the block size. 3. Appends the padding bytes to the buffer. Each padding byte has a value equal to the padding length.
Example usage: paddedData, err := Pad([]byte("example"), 8)
if err != nil {
fmt.Printf("Error padding data: %s\n", err)
}
fmt.Printf("Padded data: %x\n", paddedData)
Types ¶
This section is empty.