This project has moved. For the latest updates, please go here.


Basic

using System;
using Brettski.PasswordGenerator

public string GeneratePassword()
{
    // Generates a password with library defaults
    IPasswordGenerator pwgen = new PasswordGenerator();
    return pwgen.GeneratePassword():
}

Numeric Only

using System;
using Brettski.PasswordGenerator

public string GeneratePassword()
{
    IPasswordGenerator pwgen = new PasswordGenerator():
    pwgen.UseUpperAlpha = false;
    pwgen.UseLowerAlpha = false;
    pwgen.UseNumeric = true;    // true is default, included for example
    return pwgen.GeneratePassword();
}

Custom Character Set

using System;
using Brettski.PasswordGenerator

public string GeneratePassword()
{
    IPasswordGenerator pwgen = new PasswordGenerator():
    pwgen.UpperAlpha = @"XYZPDQ";  // Can be set to any Unicode value 256 characters max length
    pwgen.LowerAlpaha = @"xyzpdq";  // This is the same for all character value sets
    pwgen.Numbers = @"23456789";    // UpperAlpha, LowerAlpha, Numbers, Punctuation, and Special
    return pwgen.GeneratePassword();
}

Custom Character Set 2

using System;
using Brettski.PasswordGenerator

public string GeneratePassword()
{
    IPasswordGenerator pwgen = new PasswordGenerator():
    // Put your whole custom character set into one character value set up to 256 characters
    // Make sure you only use the character value set you updated
    pwgen.Special = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    pwgen.UseUpperAlpha = false;
    pwgen.UseLowerAlpha = false;
    pwgen.UseNumbers = false;
    pwgen.UseSpecial = true;
    return pwgen.GeneratePassword();
}

6 Sided Dice Roll

using System;
using Brettski.PasswordGenerator

public int RollSixSidedDie()
{
    IPasswordGenerator pwgen = new PasswordGenerator():
    pwgen.Numbers = "123456";
    pwgen.UseUpperAlpha = false;
    pwgen.UseLowerAlpha = false;
    pwgen.PasswordLength = 1;
    return (int)pwgen.GeneratePassword();
}

12 Sided Dice Roll

using System;
using Brettski.PasswordGenerator

public int RollTwelveSidedDie()
{
    IPasswordGenerator pwgen = new PasswordGenerator():
    pwgen.Numbers = "123456789abc"
    pwgen.UseUpperAlpha = false;
    pwgen.UseLowerAlpha = false;
    pwgen.PasswordLength = 1;
    string roll = pwgen.GeneratePassword();
    switch (roll)
    {
        case "a":
            roll = "10";
            break;

        case "b":
            roll = "11";
            break;

        case "c":
            roll = "12";
            break;
    }
    return (int)roll;
}

Generate Password List

using System;
using System.Collections.Generic;
using Brettski.PasswordGenerator

public List<string> GeneratePWList(int PasswordLength, int PasswordCount)
{
    IPasswordGenerator pwgen = new PasswordGenerator():
    return pwgen.GeneratePasswordList(PasswordLength, PasswordCount);
}



Template

using System;
using Brettski.PasswordGenerator

public string GeneratePassword()
{
    IPasswordGenerator pwgen = new PasswordGenerator():

}

Last edited Sep 15, 2013 at 4:18 AM by brettski, version 9

Comments

No comments yet.