Post: Login Program
03-24-2013, 09:58 PM #1
Pichu
RIP PICHU.
(adsbygoogle = window.adsbygoogle || []).push({}); You must login or register to view this content.

Saw someone post a tutorial for a log in program. Here is my source, was about to write it after I commented on his/her thread but I had to go somewhere.

    
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Security.Cryptography;


namespace Login
{
public partial class Login_Form : Form
{
public Login_Form()
{
InitializeComponent();
}


public MD5CryptoServiceProvider MD5 = new MD5CryptoServiceProvider();
public SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider();
public UTF8Encoding UTF8 = new UTF8Encoding();


string username, password, checkUsername, checkPassword;
private void Form1_Load(object sender, EventArgs e)
{
username = "F6605D694232FD462CC4147124DED870";
password = "A3B88082583ECCB947A2A77789589F26";
}


private void button1_Click(object sender, EventArgs e)
{
checkUsername = (BitConverter.ToString(MD5.ComputeHash(SHA1.ComputeHash((UTF8.GetBytes(textBox1.Text)))))).Replace("-", "");
checkPassword = (BitConverter.ToString(MD5.ComputeHash(SHA1.ComputeHash(UTF8.GetBytes(textBox2.Text))))).Replace("-", "");
if (username == checkUsername && password == checkPassword)
MessageBox.Show("Login Successful!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
else
MessageBox.Show("Incorrect Username or Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}


Creates a SHA1 hash and then a MD5 hash. You then set the desired username and password as the hashed values. This required then that the user must enter a username and password that is then hashed and equals to the already hashed username and password. This then prevents the user from just viewing the program source and retrieving the username/password and entering it in.

Obfuscating your code would also increase security.

Here is a download to the project file. The username is Pichu and the password is 1234.

You must login or register to view this content.
(adsbygoogle = window.adsbygoogle || []).push({});

The following user thanked Pichu for this useful post:

Master Ro
03-25-2013, 09:23 PM #2
Thanks for this. Will definitely help Smile, one question, can i use this on my project(s)?
03-26-2013, 01:06 AM #3
Pichu
RIP PICHU.
Originally posted by Arceus304 View Post
Thanks for this. Will definitely help Smile, one question, can i use this on my project(s)?


Yes, free to use. Just something that I wrote up in a few minutes.
03-26-2013, 06:58 PM #4
Really nice and simple login programSmile
03-26-2013, 08:45 PM #5
Sloth
Banned
Originally posted by Pichu View Post
You must login or register to view this content.

Saw someone post a tutorial for a log in program. Here is my source, was about to write it after I commented on his/her thread but I had to go somewhere.

    
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Security.Cryptography;


namespace Login
{
public partial class Login_Form : Form
{
public Login_Form()
{
InitializeComponent();
}


public MD5CryptoServiceProvider MD5 = new MD5CryptoServiceProvider();
public SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider();
public UTF8Encoding UTF8 = new UTF8Encoding();


string username, password, checkUsername, checkPassword;
private void Form1_Load(object sender, EventArgs e)
{
username = "F6605D694232FD462CC4147124DED870";
password = "A3B88082583ECCB947A2A77789589F26";
}


private void button1_Click(object sender, EventArgs e)
{
checkUsername = (BitConverter.ToString(MD5.ComputeHash(SHA1.ComputeHash((UTF8.GetBytes(textBox1.Text)))))).Replace("-", "");
checkPassword = (BitConverter.ToString(MD5.ComputeHash(SHA1.ComputeHash(UTF8.GetBytes(textBox2.Text))))).Replace("-", "");
if (username == checkUsername && password == checkPassword)
MessageBox.Show("Login Successful!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
else
MessageBox.Show("Incorrect Username or Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}


Creates a SHA1 hash and then a MD5 hash. You then set the desired username and password as the hashed values. This required then that the user must enter a username and password that is then hashed and equals to the already hashed username and password. This then prevents the user from just viewing the program source and retrieving the username/password and entering it in.

Obfuscating your code would also increase security.

Here is a download to the project file. The username is Pichu and the password is 1234.

You must login or register to view this content.


Nice one Pichu Heres the code converted to vb.net
    
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports System.Security.Cryptography




Namespace Login
Public Class Form 1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub




Public MD5 As New MD5CryptoServiceProvider()
Public SHA1 As New SHA1CryptoServiceProvider()
Public UTF8 As New UTF8Encoding()




Private username As String, password As String, checkUsername As String, checkPassword As String
Private Sub Form1_Load(sender As Object, e As EventArgs)
username = "F6605D694232FD462CC4147124DED870"
password = "A3B88082583ECCB947A2A77789589F26"
End Sub




Private Sub button1_Click(sender As Object, e As EventArgs)
checkUsername = (BitConverter.ToString(MD5.ComputeHash(SHA1.ComputeHash((UTF8.GetBytes(textBox1.Text)))))).Replace("-", "")
checkPassword = (BitConverter.ToString(MD5.ComputeHash(SHA1.ComputeHash(UTF8.GetBytes(textBox2.Text))))).Replace("-", "")
If username = checkUsername AndAlso password = checkPassword Then
MessageBox.Show("Login Successful!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Else
MessageBox.Show("Incorrect Username or Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
End Sub
End Class
End Namespace
03-27-2013, 08:55 PM #6
Originally posted by Pichu View Post
You must login or register to view this content.

Saw someone post a tutorial for a log in program. Here is my source, was about to write it after I commented on his/her thread but I had to go somewhere.

    
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Security.Cryptography;


namespace Login
{
public partial class Login_Form : Form
{
public Login_Form()
{
InitializeComponent();
}


public MD5CryptoServiceProvider MD5 = new MD5CryptoServiceProvider();
public SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider();
public UTF8Encoding UTF8 = new UTF8Encoding();


string username, password, checkUsername, checkPassword;
private void Form1_Load(object sender, EventArgs e)
{
username = "F6605D694232FD462CC4147124DED870";
password = "A3B88082583ECCB947A2A77789589F26";
}


private void button1_Click(object sender, EventArgs e)
{
checkUsername = (BitConverter.ToString(MD5.ComputeHash(SHA1.ComputeHash((UTF8.GetBytes(textBox1.Text)))))).Replace("-", "");
checkPassword = (BitConverter.ToString(MD5.ComputeHash(SHA1.ComputeHash(UTF8.GetBytes(textBox2.Text))))).Replace("-", "");
if (username == checkUsername && password == checkPassword)
MessageBox.Show("Login Successful!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
else
MessageBox.Show("Incorrect Username or Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}


Creates a SHA1 hash and then a MD5 hash. You then set the desired username and password as the hashed values. This required then that the user must enter a username and password that is then hashed and equals to the already hashed username and password. This then prevents the user from just viewing the program source and retrieving the username/password and entering it in.

Obfuscating your code would also increase security.

Here is a download to the project file. The username is Pichu and the password is 1234.

You must login or register to view this content.

wouldnt entering in a username and password and linking it into a db to check its hash with your own encryption of the info be more secure then storing any info on a exe file easily obtained
03-27-2013, 09:04 PM #7
Pichu
RIP PICHU.
Originally posted by Karma
wouldnt entering in a username and password and linking it into a db to check its hash with your own encryption of the info be more secure then storing any info on a exe file easily obtained


A database would actually be an even better method depending on what you want. If you want just a simple log in and you don't care if it is shared, then putting it inside the program would be good enough.

If you want to create a "forget password" button where the user is able to change the password and generate a new hash, a database would be best. It also gives you control over a wide range of users whereas if the login is in the program, you have no control over it.

If I was to create a log in method for multiple programs, I'd include the users computer ID, a username and a password. This means that the user can't have their username/password used on another computer because it is exclusive to their computer.
03-27-2013, 10:29 PM #8
Originally posted by Pichu View Post
A database would actually be an even better method depending on what you want. If you want just a simple log in and you don't care if it is shared, then putting it inside the program would be good enough.

If you want to create a "forget password" button where the user is able to change the password and generate a new hash, a database would be best. It also gives you control over a wide range of users whereas if the login is in the program, you have no control over it.

If I was to create a log in method for multiple programs, I'd include the users computer ID, a username and a password. This means that the user can't have their username/password used on another computer because it is exclusive to their computer.

ya the computer ID gave me an idea tho thanks lol
03-28-2013, 09:41 PM #9
Im probbaly going to use this thanks
04-01-2013, 03:37 PM #10
Might I ask what language this is in?

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo