Documentation
¶
Index ¶
- func B64ContainerCreate(header string, data []byte, lineLength int) (textContainer string)
- func B64ContainerParse(b64Container string) (header string, data []byte, err error)
- func HexContainerCreate(header string, data []byte, lineLength int) (textContainer string)
- func HexContainerParse(hexContainer string) (header string, data []byte, err error)
- func TextContainerCreate(header string, body string, lineLength int) string
- func TextContainerParse(textContainer string) (string, string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func B64ContainerCreate ¶
B64ContainerCreate creates a base64 encoded text container from a header and data.
Parameters: - header: The header of the text container. - data: The data to be encoded. - lineLength: The length of the lines in the text container.
Returns: - textContainer: The base64 encoded text container.
func B64ContainerParse ¶
B64ContainerParse parses a base64 encoded text container into a header and data.
Parameters: - b64Container: The base64 encoded text container.
Returns: - header: The header of the text container. - data: The decoded data. - err: An error if the base64 encoded text container is invalid.
func HexContainerCreate ¶
HexContainerCreate creates a text container from a header and data.
Parameters: - header: The header of the text container. - data: The data to be hex encoded. - lineLength: The length of the lines in the text container.
Returns: - textContainer: The text container.
func HexContainerParse ¶
HexContainerParse parses a text container into a header and data.
Parameters: - hexContainer: The hex text container.
Returns: - header: The header of the text container. - data: The decoded data. - err: An error if the hex text container is invalid.
func TextContainerCreate ¶
TextContainerCreate creates a text container from a header and body.
Business Logic: - The header and body are trimmed of whitespace. - The header is the first line of the text container. - The body is the remaining lines of the text container. - The body is split into lines of the specified length. - The lines are joined with a newline character.. - A single newline character is added to the end of the text container. - The text container is returned as a string.
Note:
- The header and body are only trimmed of whitespace.
- The header and body are not encoded, any encoding must be done by the caller.
- The line length is the maximum length of the lines in the text container.
- The line length must be greater than 0.
- The line length does not have a maximum value, but 80 chars is recommended for readability.
- The new line at the end of the text container is added to keep the text container consistent with the POSIX standard, stipulating that a text file is a sequence of lines ending in a newline character.
Parameters: - header: The header of the text container. - body: The body of the text container. - lineLength: The length of the lines in the text container.
Returns: - The text container as a string.
func TextContainerParse ¶
TextContainerParse parses the input text container into a header and body.
Business logic: - the text container must have a header and body. - the header and body must be separated by a newline. - the body may contain newlines, for keeping the readability of the body. - all newlines and carriage returns must be removed from the body before decoding.
Parameters:
- textContainer: The input string containing the header and body.
Returns:
- header: The parsed header string.
- body: The parsed body string.
- err: An error if the input format is invalid.
Types ¶
This section is empty.