Argentini.Halide.H3Secure.GenerateKey C# (CSharp) Method

GenerateKey() public static method

Generate a comma-separated string of 8-bit values for an encryption base key. The value is not guaranteed to be unique.
public static GenerateKey ( Int32 count ) : String
count System.Int32 Number of 8-bit numbers to generate
return String
        public static String GenerateKey(Int32 count)
        {
            String retVal = "";

            if (count > 0)
            {
                try
                {
                    byte[] randomNumber = new byte[count];
                    RNGCryptoServiceProvider Gen = new RNGCryptoServiceProvider();
                    Gen.GetBytes(randomNumber);

                    for (int x = 0; x < count; x++)
                    {
                        if (x > 0)
                        {
                            retVal += ",";
                        }

                        retVal += Convert.ToInt32(randomNumber[x]).ToString();
                    }
                }

                catch (Exception err)
                {
                    throw new Exception("Halide.H3Secure Error: " + err.ToString());
                }
            }

            return retVal;
        }