Module crypto.pem stdlib

crypto.pem
Version:
0.3.3
License:
MIT
Dependencies from vmod:
0
Imports:
2
Imported by:
0
Repository:
OS-specific
Show selected OS-specific symbols.
Backend-specific
Show selected Backend-specific symbols.

Dependencies defined in v.mod

This section is empty.

Imports

Imported by

This section is empty.

Aliases

This section is empty.

Constants

This section is empty.

Sum types

This section is empty.

Functions

#fn decode

fn decode(data string) ?(Block, string)

decode reads data and returns the first parsed PEM Block along with the rest of the string. none is returned when a header is expected, but not present or when a start of '-----BEGIN' or end of '-----END' can't be found in data

#fn new

inline
fn new(block_type string) Block

returns a new Block with the specified block_type

Structs

#struct EncodeConfig

params
pub struct EncodeConfig {
pub mut:
	// inner text wrap around
	line_length int = 64
	// line ending (alternatively '\r\n')
	line_ending string = '\n'
}

#struct Block

pub struct Block {
pub mut:
	// from preamble
	block_type string
	// optional headers
	headers map[string][]string
	// decoded contents
	data []u8
}

#fn (Block) encode

fn (block Block) encode(config EncodeConfig) !string

encode_config encodes the given block into a string using the EncodeConfig. It returns an error if block_type is undefined or if a value in headers contains an invalid character ':'

default EncodeConfig values wrap lines at 64 bytes and use '\n' for newlines

#fn (&Block) free

unsafe
fn (mut block &Block) free()

free the resources taken by the Block block

#fn (Block) header_by_key

inline
fn (block Block) header_by_key(key Header) []string

returns the selected key using the Header enum

same as block.headers[key.str()]

Interfaces

This section is empty.

Enums

#fn (Header) str

fn (header Header) str() string

str returns the string representation of the header