A custom symmetric block cipher for .NET with a 256-bit key and substitution-permutation network.
- π About
- β¨ Features
- π Getting Started
- π‘ Usage
- π API Reference
- π§ͺ Running Tests
- ποΈ Project Structure
- π€ Contributing
- π License
sBurger-256 is a custom symmetric encryption algorithm built as a .NET class library. It uses a 256-bit key and a substitution-permutation network to encrypt and decrypt data in blocks of up to 32 bytes.
The cipher derives internal transformation parameters from the key, then applies a sequence of XOR, bit-rotation, and bit-inversion operations to each byte of the data block.
β οΈ Note: This is an author's experimental cipher created for educational purposes. It has not been formally audited. Do not use it for protecting sensitive data in production.
| Characteristic | Value |
|---|---|
| Created | 2020 |
| Key size | 256 bits (32 bytes) |
| Block size | 8 .. 256 bits (1 .. 32 bytes) |
| Rounds | 1 round per byte |
| Type | Substitution-permutation network |
| Capability | Description |
|---|---|
Encryption |
Encrypts a data block (1β32 bytes) in place |
Decryption |
Decrypts a data block (1β32 bytes) in place |
GenerationSettings |
Derives internal cipher parameters from the key |
Input validation |
Guards against null, wrong-length keys, and out-of-range data blocks |
- SDK: .NET 10 SDK or later
- Language: C# 14
Clone the repository and add a project reference:
<ProjectReference Include="path\to\src\sBurger256.csproj" />Copy src/sBurger256.cs directly into your project.
using System.Security.Cryptography;
using System.Text;
// 1. Create a 256-bit key (e.g. from a passphrase via SHA-256).
byte[] key = SHA256.HashData(Encoding.UTF8.GetBytes("your passphrase"));
// 2. Initialize the cipher and generate settings.
var cipher = new sBurger256.sBurger256 { Key = key };
cipher.GenerationSettings();
// 3. Encrypt a 32-byte block.
byte[] data = Encoding.UTF8.GetBytes("Hello, sBurger-256 cipher test!!"); // 32 bytes
cipher.Encryption(data);
Console.WriteLine($"Ciphertext: {Convert.ToHexString(data)}");
// 4. Decrypt back.
cipher.Decryption(data);
Console.WriteLine($"Plaintext: {Encoding.UTF8.GetString(data)}");π See the full working demo in examples/sBurger256.Example/Program.cs.
public sBurger256()Creates a new cipher instance. Set the Key property and call GenerationSettings() before encrypting or decrypting.
| Property | Type | Description |
|---|---|---|
Key |
byte[] |
The 256-bit (32-byte) encryption key. Validated on set; internally copied. |
| Constant | Type | Value | Description |
|---|---|---|---|
KeyLength |
int |
32 |
Required key length in bytes. |
MaxBlockSize |
int |
32 |
Maximum data block size in bytes. |
public void GenerationSettings()Derives internal cipher parameters from the current key. Must be called once after setting the key and before any encryption or decryption. Throws InvalidOperationException if the key has not been set.
public byte[] Encryption(byte[] data)Encrypts the data block in place and returns the same array. Data length must be between 1 and 32 bytes. Throws ArgumentException for invalid length, InvalidOperationException if settings were not generated.
public byte[] Decryption(byte[] data)Decrypts the data block in place and returns the same array. Data length must be between 1 and 32 bytes. Throws ArgumentException for invalid length, InvalidOperationException if settings were not generated.
dotnet testTests are located in tests/sBurger256.Tests/ and use xUnit. They cover key validation, roundtrip encryption/decryption, determinism, boundary conditions, and wrong-key scenarios.
sBurger-256/
βββ π src/
β βββ π sBurger256.cs # Library source
β βββ π sBurger256.csproj
βββ π tests/
β βββ π sBurger256.Tests/ # xUnit tests
β βββ π sBurger256Tests.cs
β βββ π sBurger256.Tests.csproj
βββ π examples/
β βββ π sBurger256.Example/ # Console demo app
β βββ π Program.cs
β βββ π sBurger256.Example.csproj
βββ π Directory.Build.props # Shared build settings
βββ π Directory.Packages.props # Central package management
βββ π sBurger256.slnx # Solution file
βββ π README.md
Contributions are welcome! To get started:
- π΄ Fork the repository
- πΏ Create a feature branch (
git checkout -b feature/my-feature) - βοΈ Make your changes and add tests
- β
Run
dotnet testto verify everything passes - π¬ Open a Pull Request
This project is licensed under the MIT License.

