Bir temel şifreleme yöntemi üzerinde çalışıyorum. RijndaelManaged kullanıyorum. Bu kodu uzun zaman önce bir yerden aldım ama nerede olduğunu hatırlamıyorum.Belirtilen başlatma vektörü (IV), bu algoritma için blok boyutuyla eşleşmiyor
Kodum daha önce çalışıyordu, ancak bir şey değişti ve bunu çözemiyorum.
Kodumu çalıştırdığımda, aşağıdaki hatayı alıyorum;
Belirtilen başlatma vektörü (IV) ' bu algoritması için blok boyutu ile aynı değildir. Herhangi bir yardım takdir edilecektir
string textToEncrypt = "TEST STRING"; int keySize = 256; string hashAlgorithm = "SHA1"; string passPhrase = "AH!PSB0%FGHR$"; string saltValue = "LRT%YUR#[email protected]"; string initVector = "HR$2pIjHR$2pIj"; byte[] initVectorBytes = Encoding.ASCII.GetBytes(initVector); byte[] saltValueBytes = Encoding.ASCII.GetBytes(saltValue); byte[] plainTextBytes = Encoding.UTF8.GetBytes(textToEncrypt); PasswordDeriveBytes password = new PasswordDeriveBytes(passPhrase, saltValueBytes, hashAlgorithm, 2); byte[] keyBytes = password.GetBytes(keySize/8); RijndaelManaged symmetricKey = new RijndaelManaged(); symmetricKey.Mode = CipherMode.CBC; ICryptoTransform encryptor = symmetricKey.CreateEncryptor(keyBytes,initVectorBytes); MemoryStream memoryStream = new MemoryStream(); CryptoStream cryptoStream = new CryptoStream(memoryStream,encryptor,CryptoStreamMode.Write); cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length); cryptoStream.FlushFinalBlock(); byte[] cipherTextBytes = memoryStream.ToArray(); memoryStream.Close(); cryptoStream.Close(); string cipherText = Convert.ToBase64String(cipherTextBytes);
:
İşte benim kodudur.
Oh, işte bu! Yardım için çok teşekkür ederim. –