shared

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2025 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func B64ContainerCreate

func B64ContainerCreate(header string, data []byte, lineLength int) (textContainer string)

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

func B64ContainerParse(b64Container string) (header string, data []byte, err error)

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

func HexContainerCreate(header string, data []byte, lineLength int) (textContainer string)

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

func HexContainerParse(hexContainer string) (header string, data []byte, err error)

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

func TextContainerCreate(header string, body string, lineLength int) string

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

func TextContainerParse(textContainer string) (string, string, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL