Crypto.CryptoManager.GenerateNonce C# (CSharp) Méthode

GenerateNonce() public méthode

Generates a random value derived from a set of pre-defined alphanumeric characters.
public GenerateNonce ( Int32 length = 8 ) : byte[]
length System.Int32 The length of the random value string
Résultat byte[]
        public byte[] GenerateNonce(Int32 length = 8)
        {
            // set the random seed
            var seed = m_validNonceChars.Count();
            var result = String.Empty;
            // construct the nonce from characters randomly selected from the permissible characters
            for (int i = 0; i < length; i++)
            {
                result += m_validNonceChars[m_random.Next(0, seed)].ToString(CultureInfo.InvariantCulture);
            }

            // convert the results to an ASCII encoded byte[] and return it.
            return Encoding.ASCII.GetBytes(result);
        }