none
Generate random Initialization Vector RRS feed

  • General discussion

  • Can someone point me to a C# program that creates a random Initialization Vector. 

    Specifically the vector needs to be alphanumeric with special characters and mixed case values.  It must be 16 characters in length so it can be used to encrypt/decrypt an AES password.

    Thanks,

    Friday, February 13, 2015 6:55 PM

All replies

  • Try this:

    const string ALLOWED_CHARACTERS = "abcdeABCDE1234+-*#";
    var rnd = new Random();
    . . .
    string random_vector = 
        string.Concat( Enumerable
                           .Range( 0, 16 )
                           .Select( i => ALLOWED_CHARACTERS[rnd.Next( ALLOWED_CHARACTERS.Length )]) );

    Type all of the allowed characters in ALLOWED_CHARACTERS.


    • Edited by Viorel_MVP Friday, February 13, 2015 9:20 PM
    Friday, February 13, 2015 9:19 PM
  • Awesome!  Exactly what i needed.  Thanks a bunch Viorel
    Can someone mark Viorel's response as an answer?  I don't have the link available.
    • Edited by Clem_FRB Monday, May 4, 2015 11:03 AM
    Tuesday, February 17, 2015 1:23 PM