나는 md5 암호화를 사용하여 aC# 사용자 등록 양식을 만들었지 만 문제는 "관리자 수준"아래에 한 번만 사용자 세부 정보를 등록하려고합니다.C# 로그인 등록 양식은 사용자 정보를 한 번만 등록합니다.
내가 원하는 것은 내가 관리자 수준을 선택하고 다른 사용자로 등록하려고 시도 할 때 시스템이 다른 관리자를 등록 할 수있는 권한을 부여하지 않았을 수 있으며 "죄송합니다. 관리자가 이미 등록했습니다. 시스템 "...
내 코드입니다 ........
if (textBox1.Text != "" && textBox2.Text != "" && comboBox1.Text != "" && (comboBox1.Text == "Administrator" || comboBox1.Text == "Employee" || comboBox1.Text == "Developer"))
{
connection.Open();
string TypeUser;
int level = Convert.ToInt32(0);
TypeUser = comboBox1.Text;
if (TypeUser == "Administrator")
{
level = 1;
}
else if (TypeUser == "Employee")
{
level = 2;
}
else if (TypeUser == "Developer")
{
level = 3;
}
MySqlDataReader dr;
MySqlCommand cmd;
string sql = "INSERT INTO users(name,password,level) VALUES('" + textBox1.Text + "',MD5('" + textBox2.Text + "'),'" + level + "')";
cmd = new MySqlCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = sql;
cmd.Connection = connection;
dr = cmd.ExecuteReader();
MessageBox.Show("Registration Success !","Success",MessageBoxButtons.OK,MessageBoxIcon.Information);
connection.Close();
cmd.Dispose();
}
else
{
MessageBox.Show("All Fields must be required/something is wrong", "error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
}
해시 함수를 사용하는 것만으로는 충분하지 않으며 단지 소금을 추가하면 보안을 향상시키는 데별로 도움이되지 않습니다. 대신 HMAC를 무작위로 약 100ms의 지속 시간 동안 반복하고 소금을 해시로 저장하십시오. 'PBKDF2','password_hash','Bcrypt' 등의 함수를 사용하십시오. 요점은 공격자가 무차별 적으로 암호를 찾는 데 많은 시간을 소비하게하는 것입니다. 사용자를 보호하는 것이 중요하므로 안전한 비밀번호 방법을 사용하십시오. – zaph