22-08-16, 09:28 PM
PHP كود :
Imports System.Data.OleDb
Imports System.IO
Imports System.Security.Cryptography
Imports System.Text
Public Class Form1
Dim con As New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=db1.mdb")
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Dim db As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db1.mdb")
'Dim rs As New OleDbDataAdapter()
'Dim da As New OleDbDataAdapter("select * from noop Where Name='" & Trim(TextBox1.Text) & "' and pass='" & Trim(TextBox1.Text) & "' ", db)
'MsgBox("تم الدخول الى النظام")
Using cm = New OleDbCommand("", con)
cm.CommandText = "select count(name) from noop where name=@name and pass=@pass"
cm.Parameters.AddWithValue("@name", TextBox1.Text)
cm.Parameters.AddWithValue("@pass", Encrypt(TextBox2.Text, "thekey")) 'يجب ان تكون حفظ كلمة المرور باستخدام هذا التشفير
If con.State = ConnectionState.Closed Then con.Open()
If cm.ExecuteScalar <= 0 Then
MsgBox("Nothing Found", MsgBoxStyle.Critical, "")
Else
MsgBox("Now Welcome Back", MsgBoxStyle.Information, "")
End If
End Using
End Sub
Public Function Encrypt(clearText As String, EncryptionKey As String) As String
' string EncryptionKey = "abc123";
Dim clearBytes As Byte() = Encoding.Unicode.GetBytes(clearText)
Using encryptor As Aes = Aes.Create()
Dim pdb As New Rfc2898DeriveBytes(EncryptionKey, New Byte() {&H49, &H76, &H61, &H6E, &H20, &H4D,
&H65, &H64, &H76, &H65, &H64, &H65,
&H76})
encryptor.Key = pdb.GetBytes(32)
encryptor.IV = pdb.GetBytes(16)
Using ms As New MemoryStream()
Using cs As New CryptoStream(ms, encryptor.CreateEncryptor(), CryptoStreamMode.Write)
cs.Write(clearBytes, 0, clearBytes.Length)
cs.Close()
End Using
clearText = Convert.ToBase64String(ms.ToArray())
End Using
End Using
Return clearText
End Function
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Using cm = New OleDbCommand("", con)
cm.CommandText = "insert into noop(name,pass) values(@name,@pass)"
cm.Parameters.AddWithValue("@name", TextBox1.Text)
cm.Parameters.AddWithValue("@pass", Encrypt(TextBox2.Text, "thekey")) 'يجب ان تكون حفظ كلمة المرور باستخدام هذا التشفير
If con.State = ConnectionState.Closed Then con.Open()
Try
cm.ExecuteNonQuery()
MsgBox("Saved!")
Catch ex As Exception
MsgBox(Err.Description, MsgBoxStyle.Critical, "")
End Try
End Using
End Sub
End Class
اللهم إني أعوذ بك من غلبة الدين وغلبة العدو، اللهم إني أعوذ بك من جهد البلاء ومن درك الشقاء ومن سوء القضاء ومن شماتة الأعداء
اللهم اغفر لي خطيئتي وجهلي، وإسرافي في أمري وما أنت أعلم به مني، اللهم اغفر لي ما قدمت وما أخرت، وما أسررت وما أعلنت وما أنت أعلم به مني، أنت المقدم وأنت المؤخر وأنت على كل شيء قدير

