Kratka referenca
Kompaktni primjeri koda za brzi početak. Za detaljne objašnjenja pogledajte povezane scenarije.
PKI i certifikati
Potpisi
Razmjena ključeva i šifriranje
Uvoz/Izvoz
Brzi početak: Potpuni tijek rada
using WvdS.System.Security.Cryptography;
using WvdS.System.Security.Cryptography.KeyExchange;
using WvdS.System.Security.Cryptography.Encryption;
// 1. Konfiguracija
CryptoConfig.DefaultMode = CryptoMode.Hybrid;
// 2. Razmjena ključeva
using var mlKem = MlKem.Create(MlKemParameterSet.MlKem768);
byte[] publicKey = mlKem.ExportPublicKey();
// Pošiljatelj: Enkapsulacija
var encap = MlKem.Encapsulate(publicKey);
byte[] ciphertext = encap.Ciphertext;
byte[] senderSecret = encap.SharedSecret;
// Primatelj: Dekapsulacija
byte[] receiverSecret = mlKem.Decapsulate(ciphertext);
// 3. Derivacija ključa
byte[] aesKey = KeyDerivationExtensions.DeriveKey(
receiverSecret,
outputLength: 32,
info: Encoding.UTF8.GetBytes("AES-256-GCM"));
// 4. Šifriranje
var aes = new Aes256Gcm(aesKey);
byte[] encrypted = aes.Encrypt(plaintext);
byte[] decrypted = aes.Decrypt(encrypted);
Wolfgang van der Stille @ EMSR DATA d.o.o. - Post-Quantum Cryptography Professional
Zuletzt geändert: 30.01.2026. u 08:30