Class Aes128
- Namespace
- CryptoHives.Foundation.Security.Cryptography.Cipher
- Assembly
- CryptoHives.Foundation.Security.Cryptography.dll
AES-128 symmetric cipher implementation.
public sealed class Aes128 : SymmetricCipher, IDisposable
- Inheritance
-
Aes128
- Implements
- Inherited Members
Remarks
AES-128 uses a 128-bit (16-byte) key with 10 rounds of encryption. This is the fastest AES variant and provides adequate security for most applications.
Security level: 128 bits (quantum: 64 bits with Grover's algorithm)
Example usage:
using var aes = Aes128.Create();
aes.GenerateKey();
aes.GenerateIV();
byte[] ciphertext = aes.Encrypt(plaintext);
byte[] decrypted = aes.Decrypt(ciphertext);
Constructors
Aes128()
Initializes a new instance of the Aes128 class.
public Aes128()
Fields
KeySizeBits
Key size in bits for AES-128.
public const int KeySizeBits = 128
Field Value
KeySizeBytes
Key size in bytes for AES-128.
public const int KeySizeBytes = 16
Field Value
Properties
AlgorithmName
Gets the name of the cipher algorithm.
public override string AlgorithmName { get; }
Property Value
Examples
"AES-256", "ChaCha20", "AES-256-GCM"
IVSize
Gets the required IV/nonce size in bytes for the current mode.
public override int IVSize { get; }
Property Value
Methods
Create()
Creates a new instance of the Aes128 cipher.
public static Aes128 Create()
Returns
- Aes128
A new AES-128 cipher instance.
CreateCipherDecryptor(ReadOnlySpan<byte>, ReadOnlySpan<byte>)
Creates a decryptor transform using the specified key and IV.
protected override ICipherTransform CreateCipherDecryptor(ReadOnlySpan<byte> key, ReadOnlySpan<byte> iv)
Parameters
keyReadOnlySpan<byte>The secret key.
ivReadOnlySpan<byte>The initialization vector or nonce.
Returns
- ICipherTransform
A new cipher decryptor transform.
CreateCipherEncryptor(ReadOnlySpan<byte>, ReadOnlySpan<byte>)
Creates an encryptor transform using the specified key and IV.
protected override ICipherTransform CreateCipherEncryptor(ReadOnlySpan<byte> key, ReadOnlySpan<byte> iv)
Parameters
keyReadOnlySpan<byte>The secret key.
ivReadOnlySpan<byte>The initialization vector or nonce.
Returns
- ICipherTransform
A new cipher encryptor transform.