# README
cipherio
This Golang package allows to use block ciphers with io.Reader
and io.Writer
.
Golang already provides io.Reader
and io.Writer
implementations for cipher.Stream
, but not for cipher.BlockMode
(such as AES-CBC). The purpose of this package is to fill the gap.
Block ciphers require data size to be a multiple of the block size. The io.Reader
and io.Writer
implementations found here can either enforce this requirement or automatically apply a user-defined padding.
This package has been written with performance in mind: buffering and copies are avoided as much as possible.
# Functions
NewBlockReader wraps the given Reader to add on-the-fly encryption or decryption using the given BlockMode.
NewBlockReaderWithPadding is similar to NewBlockReader, except that any incomplete block is filled with the given padding instead of returning ErrUnexpectedEOF.
NewBlockWriter wraps the given Writer to add on-the-fly encryption or decryption using the given BlockMode.
NewBlockWriterWithPadding is similar to NewBlockWriter, except that Close fills any incomplete block with the given padding instead of returning ErrUnexpectedEOF.
# Variables
BitPadding fills an incomplete block with 0x80 followed by zeroes.
PKCS7Padding fills an incomplete block by repeating the total number of padding bytes.
ZeroPadding fills an incomplete block with zeroes.
# Interfaces
Padding defines how to fill an incomplete block.
# Type aliases
PaddingFunc allows to implement the Padding interface with a padding function.