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

CreateInitVector() public static method

Converts a comma-separated string of 18 8-bit values and converts it into a Byte array.
public static CreateInitVector ( String key ) : Byte[]
key String 18 8-bit values in a comma-separated list.
return Byte[]
        public static Byte[] CreateInitVector(String key)
        {
            Byte[] retVal = { };
            int bitLength = 16;

            try
            {
                if (!String.IsNullOrEmpty(key))
                {
                    String[] bArray = key.Replace(" ", "").Split(',');

                    if (bArray.Length == bitLength)
                    {
                        retVal = new Byte[bitLength];

                        for (Int32 x = 0; x < bArray.Length; x++)
                        {
                            retVal[x] = Convert.ToByte(bArray[x].Trim());
                        }
                    }
                }
            }

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

            return retVal;
        }