Post: C# GUI: Hex & Dec Key Generator + Exporting
01-01-2017, 09:28 PM #1
Algebra
[move]mov eax, 69[/move]
(adsbygoogle = window.adsbygoogle || []).push({}); Here is my Hex & Dec Key Generator which basically allows you to generate keys that are 20 characters long and save them to a Text Document.*

Picture of the tool :*


You must login or register to view this content.


Link to source:*


You must login or register to view this content.*


Code :


    
#region Project

#region Using's
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
#endregion

#region Code
namespace Key_Gen
{
public partial class Form1 : Form
{
#region Main
public Form1()
{
InitializeComponent();
}

private static string Hex2String(byte[] values)
{
return BitConverter.ToString(values);
}

private void Generated(object sender, EventArgs e)
{
try
{
int encrypt1 = 10;
int encrypt2 = 99;
Random r = new Random();
byte[] val3 = new Byte[8];
Int32 val = r.Next(encrypt1, encrypt2);
r.NextBytes(val3);
string input = Hex2String(val3).ToString();
txtKey.Text = val + "-" + input + "-" + val + "-" + input;
if (txtKey.Text.Count() >= 20)
{
MessageBox.Show("You have successfully generated a key \n " + txtKey.Text, "Generated", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else if(txtKey.Text.Count() < 20)
{
MessageBox.Show("You have failed to generated a key ", "Failed to Generate", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
catch(Exception ex)
{
MessageBox.Show("Failed to Generate : Original Error : \n" + ex, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}

private void Export(object sender, EventArgs e)
{
using (SaveFileDialog std = new SaveFileDialog() { Filter = "Text Documents | *.txt", ValidateNames = true })
{
if (std.ShowDialog() == DialogResult.OK)
{
using (TextWriter tw = new StreamWriter(new FileStream(std.FileName, FileMode.Create), Encoding.ASCII))
{

tw.WriteLine("Key Generated:\t" + txtKey.Text);
}
}
}
}

#endregion
}
}
#endregion

#endregion

Last edited by Algebra ; 01-20-2017 at 03:09 AM.
01-02-2017, 11:57 AM #2
TheCrew
Save Point
thanks

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo