none
need key encription RRS feed

  • Question

  • Hi all,

    how do I create secret key for:

    key = Encoding.UTF8.GetBytes("key must contain 24 characters and be ISO-8859-1 compatible");

    ?

    Tuesday, December 14, 2010 2:21 PM

Answers

  • public string GenerateKey()
    {
        string strKey = String.Empty;
    
        RNGCryptoServiceProvider rngProvider = new RNGCryptoServiceProvider();
        byte[] myKey = new byte[24];
        rngProvider.GetBytes(myKey);
        myKey.ToList().ForEach(b => strKeyD += b.ToString("x2"));
    
        return strKey;
    }
    
    • Marked as answer by Cookie Luo Tuesday, December 21, 2010 3:10 AM
    Tuesday, December 14, 2010 8:39 PM