crypto.pem #
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 #
fn new(block_type string) Block
returns a new Block
with the specified block_type
enum Header #
enum Header {
proctype
contentdomain
dekinfo
origid_asymm
origid_symm
recipid_asymm
recipid_symm
cert
issuercert
micinfo
keyinfo
crl
}
Headers as described in RFC 1421 Section 9
fn (Header) str #
fn (header Header) str() string
str
returns the string representation of the header
struct Block #
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 #
fn (block Block) header_by_key(key Header) []string
returns the selected key using the Header enum
same as block.headers[key.str()]
struct EncodeConfig #
struct EncodeConfig {
pub mut:
// inner text wrap around
line_length int = 64
// line ending (alternatively '\r\n')
line_ending string = '\n'
}