O código a baixo é o para construção de um pequeno gerador de senhas básico, porém mesmo assim voce precisa ter um pouquinho de conhecimento para poder identificar os objetos e seus nomes dentro do código, se não mesmo não vai funcionar no seu projeto, numa oportunidade irei fazer um vídeo e postar no meu canal do youtube. Segue o código:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Gerador_de_senhas
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private const string SenhaCaracteresValidos = "ABCDEFGHIJKLMNOPKRSTUVYXWZabcdefghijklmnopqrstuvwxyz1234567890@#!?";
        private const string SenhaCaracteresValidos1 = "ABCDEFGHIJKLMNOPKRSTUVYXWZabcdefghijklmnopqrstuvwxyz";
        private const string SenhaCaracteresValidos2 = "1234567890";
        private const string SenhaCaracteresValidos3 = "ABCDEFGHIJKLMNOPKRSTUVYXWZabcdefghijklmnopqrstuvwxyz1234567890";
        //GERANDO SENHA COM LETRA, NUMERO E CARACTER ESPECIAL
        public string CreatePassword(int tamanho)
        {
            int valormaximo = SenhaCaracteresValidos.Length;
            Random random = new Random(DateTime.Now.Millisecond);
            StringBuilder senha = new StringBuilder(tamanho);
            for (int indice = 0; indice < tamanho; indice++)
            {
                senha.Append(SenhaCaracteresValidos[random.Next(0, valormaximo)]);
            }
            return senha.ToString();
        }
        //GERANDO SENHA COM LETRA
        public string CreatePassword1(int tamanho)
        {
            int valormaximo = SenhaCaracteresValidos1.Length;
            Random random = new Random(DateTime.Now.Millisecond);
            StringBuilder senha = new StringBuilder(tamanho);
            for (int indice = 0; indice < tamanho; indice++)
            {
                senha.Append(SenhaCaracteresValidos1[random.Next(0, valormaximo)]);
            }
            return senha.ToString();
        }
        //GERANDO SENHA COM NUMERO
        public string CreatePassword2(int tamanho)
        {
            int valormaximo = SenhaCaracteresValidos2.Length;
            Random random = new Random(DateTime.Now.Millisecond);
            StringBuilder senha = new StringBuilder(tamanho);
            for (int indice = 0; indice < tamanho; indice++)
            {
                senha.Append(SenhaCaracteresValidos2[random.Next(0, valormaximo)]);
            }
            return senha.ToString();
        }
        //GERANDO SENHA COM LETRA E NUMERO
        public string CreatePassword3(int tamanho)
        {
            int valormaximo = SenhaCaracteresValidos3.Length;
            Random random = new Random(DateTime.Now.Millisecond);
            StringBuilder senha = new StringBuilder(tamanho);
            for (int indice = 0; indice < tamanho; indice++)
            {
                senha.Append(SenhaCaracteresValidos3[random.Next(0, valormaximo)]);
            }
            return senha.ToString();
        }
        private void btnGerar_Click(object sender, EventArgs e)
        {
            int numero;
            string result;
            numero = Convert.ToInt32(mtbSize.Text);
            result = CreatePassword(numero);
            txtSenhaGerada.Text = result;
        }
        private void btnFechar_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
        private void btnCopiar_Click(object sender, EventArgs e)
        {
            Clipboard.SetText(txtSenhaGerada.Text);
        }
        private void btnL_Click(object sender, EventArgs e)
        {
            int numero;
            string result;
            numero = Convert.ToInt32(mtbSize.Text);
            result = CreatePassword1(numero);
            txtSenhaGerada.Text = result;
        }
        private void btnN_Click(object sender, EventArgs e)
        {
            int numero;
            string result;
            numero = Convert.ToInt32(mtbSize.Text);
            result = CreatePassword2(numero);
            txtSenhaGerada.Text = result;
        }
        private void btnLN_Click(object sender, EventArgs e)
        {
            int numero;
            string result;
            numero = Convert.ToInt32(mtbSize.Text);
            result = CreatePassword3(numero);
            txtSenhaGerada.Text = result;
        }
    }
}
Voltado para assuntos de tecnologia da informação e noticias e downloads do genero
Assinar:
Postar comentários (Atom)
- 
Estratégia de Operação em Opções Binárias: Rejeição de Preço e Fluxo de Velas Estratégia de operação em opções binárias baseada na rejei...
 - 
Windows Server 2025 Windows Server 2025 , released on November 1, 2024, is the latest version of Microsoft's server operating system. Th...
 - 
Introduction pfSense® is a widely acclaimed open-source firewall and router software that offers a plethora of features tailored for netw...
 
NEOBUX
https://www.neobux.com/imagens/banner9/?u=arimateiab&u3=34402090
Nenhum comentário:
Postar um comentário