C# Encryption Algorithms?

You're right, using the same IV is a bad practice, especially if either the Key or IV are hard coded. I'd recommend using the AesManaged class. It uses the AES algorithm, the current standard.

Generating an IV is fairly simple.

You're right, using the same IV is a bad practice, especially if either the Key or IV are hard coded. I'd recommend using the AesManaged class. It uses the AES algorithm, the current standard.

Generating an IV is fairly simple: var aes = new AesManaged(); //Set your KeySize if you will generate a key too. Aes.GenerateIV(); var iv = aes. IV; That's a simple way of getting a new initialization vector.

If your goal is to encrypt a file, you can store the File, but what will you do with the Key? Hard coding it within your application is generally not a very good way of doing it. If your application will be password based, then you can generate the key from Rfc2898DeriveBytes to get a byte array based on a password.

This way, your application never knows what the encryption key is. Here is an example for writing the IV to a file, then the file contents. Using (AesManaged aes = new AesManaged()) { //Set the Key here.Aes.GenerateIV(); using (var transform = aes.CreateEncryptor()) { using (var fileStream = new FileStream("C:\\in.

Txt", FileMode. Open)) { using (var saveTo = new FileStream("C:\\out. Txt", FileMode.

Create)) { using (var cryptoStream = new CryptoStream(saveTo, transform,CryptoStreamMode. Write)) { var iv = aes. IV; cryptoStream.

Write(iv, 0, iv. Length); fileStream. CopyTo(cryptoStream); } } } } }.

Meaning, if for instance the program encrypted the file and then after that for example it crashed, I am left with an encrypted file and I know nothing about the key, so the information is lost to me and I cannot restore the information that was encrypted. – user765964 Jun 8 at 9:36.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions