zipcrypto

package
v0.0.0-...-2145608 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPassword = errors.New("invalid password")
	ErrNotEncrypted    = errors.New("not encrypted with zipcrypto")
)
View Source
var (
	ErrInvalidHeader        = errors.New("invalid header")
	ErrEncryptionFlagNotSet = fmt.Errorf("%w: encryption flag not set", ErrInvalidHeader)
)

Functions

func NewReader

func NewReader(fh *zip.FileHeader, r io.Reader, password []byte) (io.Reader, error)

NewReader creates a reader that validates the given password and decrypts data as it is read.

The password is validated against the zip.FileHeader provided

func NewWriter

func NewWriter(fh *zip.FileHeader, w io.Writer, password []byte) (io.Writer, error)

NewWriter uses a properly configured zip.FileHeader and password to create a writer that encrypts as data is written to it.

Note: due to this implementation being external to archive/zip, the zip.FileHeader must be filled out (including the Flags, CRC32, and the CompressedSize64 must be set 12 bytes longer than the actual value).

This is because (zip.Writer).CreateRaw creates the writer that must be wrapped by this function and the zip.FileHeader cannot be modified once CreateRaw has been called.

Types

This section is empty.

Jump to

Keyboard shortcuts

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