format

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package format implements the age file format.

Index

Constants

View Source
const BytesPerLine = ColumnsPerLine / 4 * 3
View Source
const ColumnsPerLine = 64

Variables

View Source
var EncodeToString = b64.EncodeToString

Functions

func DecodeString

func DecodeString(s string) ([]byte, error)

Types

type Header struct {
	Recipients []*Stanza
	MAC        []byte
}

func Parse

func Parse(input io.Reader) (*Header, io.Reader, error)

Parse returns the header and a Reader that begins at the start of the payload.

func (*Header) Marshal

func (h *Header) Marshal(w io.Writer) error

func (*Header) MarshalWithoutMAC

func (h *Header) MarshalWithoutMAC(w io.Writer) error

type ParseError

type ParseError struct {
	// contains filtered or unexported fields
}

func (*ParseError) Error

func (e *ParseError) Error() string

func (*ParseError) Unwrap added in v1.1.0

func (e *ParseError) Unwrap() error

type Stanza

type Stanza struct {
	Type string
	Args []string
	Body []byte
}

Stanza is assignable to age.Stanza, and if this package is made public, age.Stanza can be made a type alias of this type.

func (*Stanza) Marshal

func (r *Stanza) Marshal(w io.Writer) error

type StanzaReader added in v1.1.0

type StanzaReader struct {
	// contains filtered or unexported fields
}

func NewStanzaReader added in v1.1.0

func NewStanzaReader(r *bufio.Reader) *StanzaReader

func (*StanzaReader) ReadStanza added in v1.1.0

func (r *StanzaReader) ReadStanza() (s *Stanza, err error)

type WrappedBase64Encoder

type WrappedBase64Encoder struct {
	// contains filtered or unexported fields
}

WrappedBase64Encoder is a standard base64 encoder that inserts an LF character every ColumnsPerLine bytes. It does not insert a newline neither at the beginning nor at the end of the stream, but it ensures the last line is shorter than ColumnsPerLine, which means it might be empty.

func NewWrappedBase64Encoder

func NewWrappedBase64Encoder(enc *base64.Encoding, dst io.Writer) *WrappedBase64Encoder

NewWrappedBase64Encoder returns a WrappedBase64Encoder that writes to dst.

func (*WrappedBase64Encoder) Close

func (w *WrappedBase64Encoder) Close() error

func (*WrappedBase64Encoder) LastLineIsEmpty

func (w *WrappedBase64Encoder) LastLineIsEmpty() bool

LastLineIsEmpty returns whether the last output line was empty, either because no input was written, or because a multiple of BytesPerLine was.

Calling LastLineIsEmpty before Close is meaningless.

func (*WrappedBase64Encoder) Write

func (w *WrappedBase64Encoder) Write(p []byte) (int, error)

type WriterFunc

type WriterFunc func(p []byte) (int, error)

func (WriterFunc) Write

func (f WriterFunc) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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