encryption - Generate Initialization Vector (IV) and Salt values in .NET -


I am using .NET cryptography library to encrypt / decrypt some text. I would like to generate initial vector (IV) and salt for the user during encryption so that everyone needs to provide them, pass-phrase. After the text is encrypted, I will present the user the salt value and initial vector so they can send them to the receiver of the message.

How do I use the net to generate salt? Initial vector (IV) out of real encryption steps? Currently encryption / decryption methods I have accepted salt and initial vector as parameters, as strings.

I tried to use the following code which generates an initialization vector, but the size of the return value always comes back bigger than the 16 bytes required for the initial vector in AES. New RNGCryptoServiceProvider () Dim Buffer Byte () = New Byte (15) {} rng.GetBytes (Fond) Return Convert as the RENDER to <. ToBase64String (buff)

The size of the fourth is determined by the algorithm (eg For, 16 bytes). This means that the size of the byte array is fixed, not the string that you make. You can not pass a string as a quarter, unless you can convert it to the appropriate byte array with the required size.

Comments