Esempio n. 1
0
        /// <summary>
        /// Generates a random string representing a sequence of Base64 digits.
        /// </summary>
        /// <param name="random">The pseudo-random engine that will be used to generate bits from which the return value is derived.</param>
        /// <param name="length">The length of the string to be generated.</param>
        /// <param name="characterPairs">The specific Base64 character set used to generate the random string.</param>
        /// <returns>A random string, with each character being a uniformly random selection from the Base64 character set specified.</returns>
        /// <seealso cref="Base64String(IRandom, int)"/>
        /// <seealso cref="Base64CharacterPairs"/>
        public static string Base64String(this IRandom random, int length, Base64CharacterPairs characterPairs)
        {
            switch (characterPairs)
            {
            case Base64CharacterPairs.PlusSlash: return(random.Base64String(length, _base64PlusSlashCharacters));

            case Base64CharacterPairs.HyphenUnderscore: return(random.Base64String(length, _base64HyphenUnderscoreCharacters));

            case Base64CharacterPairs.PeriodUnderscore: return(random.Base64String(length, _base64PeriodUnderscoreCharacters));

            case Base64CharacterPairs.PeriodHyphen: return(random.Base64String(length, _base64PeriodHyphenCharacters));

            case Base64CharacterPairs.UnderscoreColon: return(random.Base64String(length, _base64UnderscoreColonCharacters));

            case Base64CharacterPairs.UnderscoreHyphen: return(random.Base64String(length, _base64UnderscoreHyphenCharacters));

            case Base64CharacterPairs.BangHyphen: return(random.Base64String(length, _base64BangHyphenCharacters));

            case Base64CharacterPairs.TildeHyphen: return(random.Base64String(length, _base64TildeHyphenCharacters));

            default: throw new System.NotImplementedException();
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Generates a random string representing a sequence of Base64 digits.
 /// </summary>
 /// <param name="random">The pseudo-random engine that will be used to generate bits from which the return value is derived.</param>
 /// <param name="length">The length of the string to be generated.</param>
 /// <returns>A random string, with each character being a uniformly random selection from the default Base64 character set.</returns>
 /// <seealso cref="Base64String(IRandom, int, Base64CharacterPairs)"/>
 public static string Base64String(this IRandom random, int length)
 {
     return(random.Base64String(length, _base64PlusSlashCharacters));
 }
Esempio n. 3
0
 public void OnGenerateBase64Strings()
 {
     GenerateStrings(() => _random.Base64String(stringLength));
 }