>>>var algorithm = new RijndaelManaged { KeySize = 256, BlockSize = 128 }; >>>var key = new Rfc2898DeriveBytes(password, Encoding.ASCII.GetBytes("")); >>>>>>In the second line it says "Salt is not at least eight bytes". When I put in 8 spaces or 8 zeros it does not throw an error, but the resulting string is completely incorrect. Do you have any idea what could be the "Default" salt?
> String password = "ÕÖì/ŸŒ@‘PŒ{'VûGuï…‰È*RÞÖ¸‚þ.÷}"; > > byte[] keyArray = UTF8Encoding.UTF8.GetBytes("abcdefghijasdflkgdfkisluguslijon"); // AES-256 key > > byte[] toEncryptArray = Encoding.Unicode.GetBytes(password); > > var algorithm = new RijndaelManaged(); > var key = new Rfc2898DeriveBytes(password, Encoding.ASCII.GetBytes("00000000")); > > algorithm.Key = key.GetBytes(algorithm.KeySize / 8); > algorithm.IV = key.GetBytes(algorithm.BlockSize / 8); > algorithm.Mode = CipherMode.ECB; > algorithm.Padding = PaddingMode.Zeros; > > String output; > > ICryptoTransform decryptor = algorithm.CreateDecryptor(algorithm.Key, algorithm.IV); > > // Create the streams used for decryption. > using (MemoryStream msDecrypt = new MemoryStream(toEncryptArray)) > { > using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read)) > { > using (StreamReader srDecrypt = new StreamReader(csDecrypt)) > { > > // Read the decrypted bytes from the decrypting stream > // and place them in a string. > output = srDecrypt.ReadToEnd(); > } > } > } > > MessageBox.Show(output); //Shows a longer string with strange characters. >The 0s you have in your key are equivalent to (byte)48, so you get an array filled with (byte)48. Try setting your key to byte[8]. You want a byte array with all of its values set to 0.