Table of Contents

Bodu.Security.Cryptography.Extensions Namespace

Bodu.Security.Cryptography

Purpose

Bodu.Security.Cryptography.Extensions holds the extension-method surfaces that compose on top of the BCL cryptography types and the Bodu cipher / hash bases. The types here add convenience methods that keep the cipher / hash usage sites concise without pulling additional dependencies into the core algorithms.

Key types

Example

using Bodu.Security.Cryptography;
using Bodu.Security.Cryptography.Extensions;

using var blowfish = Blowfish.Create();
blowfish.Key = key;
blowfish.GenerateIV();
blowfish.BlockMode    = CipherModeKind.CBC;
blowfish.BlockPadding = PaddingModeKind.PKCS7;

// SymmetricAlgorithmExtensions.Encrypt / Decrypt: one-shot over a span or array -
// creates the transform, runs it, and disposes it for you.
byte[] ciphertext = blowfish.Encrypt(plaintext);
byte[] plain      = blowfish.Decrypt(ciphertext);

Notes

Classes

AeadBlockCipherModeTransformExtensions

Extends IAeadBlockCipherModeTransform with one-shot encrypt/decrypt overloads that handle the associated-data step, size the output buffer correctly, and return the ciphertext + tag (or recovered plaintext) as a single freshly allocated array.

AeadTransformExtensions

Provides convenience helpers over IAeadTransform that size the output buffer and return a freshly allocated array, for callers who prefer arrays to caller-supplied spans.

HashAlgorithmExtensions

Extends HashAlgorithm with incremental input, async hashing of streams, and constant-time verification against expected digests supplied as bytes, spans, memory, or hex strings.

ICryptoTransformExtensions

Extends ICryptoTransform with one-shot, span/memory-aware, stream-to-stream, and async transform helpers - sized buffers, finalization, and stream pumping rolled into single calls.

SymmetricAlgorithmExtensions

Extends SymmetricAlgorithm with one-shot encrypt/decrypt of buffers, stream-to-stream pipelines, awaitable async variants, and try-pattern transform creation that surfaces validation failures without exceptions.

SymmetricStreamAlgorithmExtensions

Extends SymmetricStreamAlgorithm with one-shot encrypt/decrypt of buffers and stream-to-stream pipelines, mirroring the convenience surface offered for block ciphers.

TweakableSymmetricAlgorithmExtensions

Extends TweakableSymmetricAlgorithm with try-pattern transform creation that surfaces invalid key, IV, or tweak material as a false return rather than a thrown CryptographicException.