반응형
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;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Security.Cryptography;
namespace LOGIN
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
OleDbConnection conn;
string connectionString = "Provider=MSDAORA;Password=1234;User ID=TAEHO"; //oracle 서버 연결
private void login_Click_1(object sender, EventArgs e)
{
conn = new OleDbConnection(connectionString);
try
{
conn.Open(); //데이터베이스 연결
OleDbCommand cmd = new OleDbCommand();
cmd.CommandText = "select * from member where member_id ='" + textBox1.Text + "'";
cmd.CommandType = CommandType.Text; //검색명령을 쿼리 형태로
cmd.Connection = conn;
OleDbDataReader read = cmd.ExecuteReader(); //select 회원ID from 회원 결과
if (!(read.Read()))
labelError.Text = "존재하지 않는 아이디입니다";
else
{
if (read.GetValue(2).ToString() != textBox2.Text)
{
labelError.Text = "비밀번호가 일치하지 않습니다";
}
string input_value = textBox2.Text;
// SHA256 해시 생성
SHA256 hash1 = new SHA256Managed();
byte[] bytes1 = hash1.ComputeHash(Encoding.ASCII.GetBytes(input_value));
// 16진수 형태로 문자열 결합
StringBuilder sb1 = new StringBuilder();
foreach (byte b1 in bytes1)
sb1.AppendFormat("{0:x2}", b1);
// 입력값의 해시결과
String hash_value = sb1.ToString();
if (read.GetValue(2).ToString() != hash_value)
{
labelError.Text = "비밀번호가 일치하지 않습니다";
}
else
{
labelError.Text = read.GetValue(1).ToString() + "님 환영합니다";
}
}
read.Close();
conn.Close();
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex.Message); //에러 메세지
}
}
private void loginSignupbutton_Click_1(object sender, EventArgs e)
{
Form2 frm = new Form2();
frm.ShowDialog();
}
private void button24_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
근데 뭐가 뒤틀렸는지
오라클서버에 접속을 못하네
난 모르게따
반응형