bfcodec 0.0.4
Tools and a C/C++ library to manipulate BFCodec-encrypted content
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
BFCodec Class Reference

C++23 wrapper around the bfcodec C library. More...

#include <bfcodecpp.h>

Public Member Functions

 BFCodec (const BFCodec &)=delete
 
BFCodecoperator= (const BFCodec &)=delete
 
 BFCodec (BFCodec &&other) noexcept
 
BFCodecoperator= (BFCodec &&other) noexcept
 
std::expected< void, BFCodecErrorexpandKey (std::span< const std::byte > key)
 Expand key into the codec state (calls bfcodec_expand_key).
 
std::expected< void, BFCodecErrordecrypt (std::span< std::byte > data, std::span< const std::byte, 8 > iv)
 Decrypt data in place with CBC.
 
std::expected< void, BFCodecErrorencrypt (std::span< std::byte > data, std::span< const std::byte, 8 > iv)
 Encrypt data in place with CBC.
 

Static Public Member Functions

static std::expected< BFCodec, BFCodecErrorcreate ()
 Create a codec instance (calls bfcodec_init()).
 
static std::string message (BFCodecError e)
 Human-readable message for BFCodecError.
 

Detailed Description

C++23 wrapper around the bfcodec C library.

Use create() to obtain a codec; expandKey(), decrypt(), and encrypt() return std::expected.

Member Function Documentation

◆ create()

std::expected< BFCodec, BFCodecError > BFCodec::create ( )
static

Create a codec instance (calls bfcodec_init()).

Returns
The codec on success, or std::unexpected(BFCodecError::InitFailed) on failure.

◆ decrypt()

std::expected< void, BFCodecError > BFCodec::decrypt ( std::span< std::byte >  data,
std::span< const std::byte, 8 >  iv 
)

Decrypt data in place with CBC.

Parameters
dataBuffer to decrypt; data.size() must be a multiple of 8.
ivInitialisation vector; must be exactly 8 bytes.
Returns
void on success, or std::unexpected(BFCodecError) on failure.

◆ encrypt()

std::expected< void, BFCodecError > BFCodec::encrypt ( std::span< std::byte >  data,
std::span< const std::byte, 8 >  iv 
)

Encrypt data in place with CBC.

Parameters
dataBuffer to encrypt; data.size() must be a multiple of 8.
ivInitialisation vector; must be exactly 8 bytes.
Returns
void on success, or std::unexpected(BFCodecError) on failure.

◆ expandKey()

std::expected< void, BFCodecError > BFCodec::expandKey ( std::span< const std::byte >  key)

Expand key into the codec state (calls bfcodec_expand_key).

Parameters
keyKey bytes; may be any non-empty length.
Returns
void on success, or std::unexpected(BFCodecError) on failure.

◆ message()

std::string BFCodec::message ( BFCodecError  e)
static

Human-readable message for BFCodecError.

Parameters
eThe error code.
Returns
A string message describing the error.

The documentation for this class was generated from the following files: