Пример #1
0
 private static void randomize(this RandomString str)
 {
     str._buff = new char[str._size];
     for (var iterate = 0; iterate < str._size; iterate++)
     {
         var i = str.RandomNumber(1, 100);
         str.rngChar((i <= 25 ? AlphanumericFormat.Numeric : i <= 55 ? AlphanumericFormat.Uppercase : i <= 85 ? AlphanumericFormat.Lowercase : AlphanumericFormat.NonAlphanumeric), iterate);
     }
     str.ensureAllChars();
     str._isRandomized = true;
 }
Пример #2
0
 private static int getUnusedPosition(this RandomString str, AlphanumericFormat format)
 {
     do
     {
         var i = str.RandomNumber(0, str._size);
         if (str.checkPositions(i))
         {
             return(i);
         }
     } while (true);
 }
Пример #3
0
        private static void rngChar(this RandomString str, AlphanumericFormat format, int position)
        {
            var byteBuffer = 0;

            switch (format)
            {
            case AlphanumericFormat.Numeric:
                byteBuffer = str.RandomNumber(0, 9);
                break;

            case AlphanumericFormat.Lowercase:
            case AlphanumericFormat.Uppercase:
                byteBuffer = str.RandomNumber(0, 26);
                break;

            default:
                byteBuffer = str.RandomNumber(0, str._specialChars.Length);
                break;
            }

            str.generateChar(format, position, byteBuffer);
        }