Skip to content

VanHakobyan/RNGCryptoServicePassGen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

RNGCryptoService password generator

Example. The most useful method on RNGCryptoServiceProvider is the GetBytes method. And because this type implements Dispose, you can enclose it in a using-statement. We fill a four-byte array with GetBytes ten times.

using System;
using System.Security.Cryptography;

class Program
{
    static void Main()
    {
        using (RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider())
        {
            // Buffer storage.
            byte[] data = new byte[4];

            // Ten iterations.
            for (int i = 0; i < 10; i++)
            {
                // Fill buffer.
                rng.GetBytes(data);

                // Convert to int 32.
                int value = BitConverter.ToInt32(data, 0);
                Console.WriteLine(value);
            }
        }
    }
}

The library consists of

public enum optionPass
 {
       pasSize,
       pasUpperOnly,
       pasSmallOnly,
       pasDigitOnly,
       pasDigitUpperSmall

}
...
...
...
public Password(optionPass passOpt, int length)
{
      getPassword = NewPassword(passOpt, length).ToString();
}

Releases

No releases published

Packages

No packages published

Languages