Create Authorization class that automatically generates a PIN number


I need assistance on how to create an AuthorizationPIN class that automatically generates a random PIN number when a user logs in. The way the app is currently constructed is when a user logs in and it calls back a URL. By generating a PIN it will create an authorization workflow to allow the user to authenticate the app. It will be a 10character pin (0-9, A-Z) all uppercase, that the user enters into a config file instead of that URL. The user goes thru a auth process and instead of calling back a URL there will be a page to randonly generate a pin. The randomly generated PIN and access code will be stored in a new database table. Hopefully this makes sense.


Anyone with any suggestions for this.


What have you done so far with the AuthorizationPIN class, @midardy? Can you post some code here that the members familiar with .net can help you with?


Sure this is what I have so far. I don’t know if I’m on the right path at all. This is something I haven’t done before.

using System;
using System.Linq;
using System.Text;

namespace AuthorizationPIN
public class AuthorizationPIN
    public int Id { get; set; }
    public string AccessCode { get; set; }
    public string PIN { get; set; }

public class RandomGenerator
    // Generate a random number between two numbers  
    public int RandomNumber(int min, int max)
        Random random = new Random();
        return random.Next(min, max);
    // Generate a random string with a given size  
    public string RandomString(int size, bool upperCase)
        StringBuilder builder = new StringBuilder();
        Random random = new Random();
        char ch;
        for (int i = 0; i < size; i++)
            ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65)));
        if (upperCase)
            return builder.ToString().ToUpper();
        return builder.ToString();
    private static Random random = new Random();
    public static string RandomString(int length)
        const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        return new string(Enumerable.Repeat(chars, length)
          .Select(s => s[random.Next(s.Length)]).ToArray());




This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.