/// <summary> /// Processes the complexity. /// </summary> /// <param name="complexity">The complexity.</param> /// <returns>An array with Categories in complexity</returns> /// <externalUnit/> /// <revision revisor="dev01" date="1/29/2010" version="1.1.6.1"> /// Member Created /// </revision> public static List <Categories> ProcessComplexity(long complexity) { var returnValue = new List <Categories>(); foreach (Categories cat in Enum.GetValues(typeof(Categories))) { for (int i = 0; i < StringComplexity.CheckComplexityCategory(complexity, cat); i++) { returnValue.Add(cat); } } return(returnValue); }
/// <summary> /// Generates the string. /// </summary> /// <param name="length">The length.</param> /// <param name="complexity">The complexity.</param> /// <returns>The random string</returns> /// <externalUnit/> /// <revision revisor="dev01" date="1/29/2010" version="1.1.6.1"> /// Member Created /// </revision> public string GenerateString( int length, long complexity) { StringBuilder tempString = new StringBuilder(length); var categoryList = StringComplexity.ProcessComplexity(complexity); var restOfCategories = StringComplexity.ProcessComplexity(complexity); StringComplexity.Categories category; byte[] bytesHolder = SequoiaRandom.RandomBytes(length); Array listOfCategories = Enum.GetValues(typeof(StringComplexity.Categories)); foreach (byte letter in bytesHolder) { int index = 0; if (categoryList.Count > 0) { index = SequoiaRandom.RandomNumber( 0, categoryList.Count - 1); category = categoryList[index]; categoryList.RemoveAt(index); } else { index = SequoiaRandom.RandomNumber( 0, restOfCategories.Count - 1); category = restOfCategories[index]; } char character = this.GetCharacter(letter, category); tempString.Append(character); } return(tempString.ToString()); }