i would like to know if it is possible to translate my code according to a database(currently using microsoft sql server)
the code i have it is encrypting and decryption on a file inside the microsoft visual studio project
i want to connect it to the database
this code is not connected to the database , is there a way of doing it
please help!!!!
'Form1.vb ~ by HazardEdit // HazardEdit.com // youtube.com/HazardEdit
Imports System.Net.Mail
Public Class Form1
Public Const WM_NCLBUTTONDOWN As Integer = &HA1
Public Const HT_CAPTION As Integer = &H2
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32
Private Declare Function ReleaseCapture Lib "user32.dll" () As Int32
Dim encdec As EncryptDecrypt
Dim passc As String
Dim userc As String
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click
Close()
End Sub
Private Sub LinkLabel1_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
reg_form.Visible = True
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If filethere(TextBox1.Text & "username.login") = True And filethere(TextBox1.Text & "password.login") Then
Dim userreader As New System.IO.StreamReader(TextBox1.Text & "username.login")
TextBox3.Text = userreader.ReadToEnd
TextBox3.Text = encdec.Decrypt(TextBox3.Text)
userreader.Close()
Dim passreader As New System.IO.StreamReader(TextBox1.Text & "password.login")
TextBox4.Text = passreader.ReadToEnd
TextBox4.Text = encdec.Decrypt(TextBox4.Text)
passreader.Close()
If TextBox3.Text = TextBox1.Text And TextBox4.Text = TextBox2.Text Then
Dim smtp As New SmtpClient
Dim message As New MailMessage
smtp.Host = "smtp.gmail.com"
smtp.EnableSsl = True
smtp.Port = 587
smtp.Credentials = New Net.NetworkCredential("click.noreply@gmail.com", "ER8GD1F62BX16VXXD54T")
message.To.Add("f319782@rmqkr.net")
message.From = New MailAddress("click@gmail.com")
message.Subject = ("Logged in:" & TimeString & " | " & DateString)
message.Body = ("Logged in:" & TimeString & " | " & DateString)
MsgBox("You are now succesfully logged in!")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
Else
MsgBox("Error! Username or password is wrong!")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
End If
Else
MsgBox("This user doesn't exist!")
End If
End Sub
Function filethere(ByVal filename As String) As Boolean
If (Dir(filename) = "") Then
filethere = False
Else
filethere = True
End If
End Function
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.MouseDown
End Sub
Private Sub Panel1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseDown, Panel1.Paint
If (e.Button = Windows.Forms.MouseButtons.Left) Then
ReleaseCapture()
SendMessage(Handle.ToInt32, WM_NCLBUTTONDOWN, HT_CAPTION, 0)
End If
End Sub
Private Sub Panel1_Paint(sender As Object, e As PaintEventArgs)
End Sub
End Class
' ~ EncryptDecrypt.vb ~ by HazardEdit // HazardEdit.com // youtube.com/HazardEdit
Public Class EncryptDecrypt
Public Shared Function Encrypt(ByVal text_to_Encrypt As String) As String
Dim encstr As String = text_to_Encrypt
Dim Val As String = Nothing
Dim Result As New System.Text.StringBuilder
For Each Character As Byte In System.Text.ASCIIEncoding.ASCII.GetBytes(text_to_Encrypt)
Result.Append(Convert.ToString(Character, 2).PadLeft(8, "0"))
Result.Append(" ")
Next
Val = Result.ToString.Substring(0, Result.ToString.Length - 1)
encstr = Val
Dim ret As String = converttoline(encstr)
Return ret
End Function
Public Shared Function Decrypt(ByVal Text_to_Decrypt As String) As String
Dim decret As String = Text_to_Decrypt
decret = converttoline(decret)
Dim Val As String = Nothing
Dim Characters As String = System.Text.RegularExpressions.Regex.Replace(decret, "[^01]", "")
Dim ByteArray((Characters.Length / 8) - 1) As Byte
For Index As Integer = 0 To ByteArray.Length - 1
ByteArray(Index) = Convert.ToByte(Characters.Substring(Index * 8, 8), 2)
Next
Val = System.Text.ASCIIEncoding.ASCII.GetString(ByteArray)
decret = Val
Return decret
End Function
Private Shared Function converttoline(ByVal text_to_convert As String) As String
Dim str As String = text_to_convert
' If str.Contains("É9;$,c#¾˜xžïw;½ƒÏ+ÃNòcñçâ32½ƒhâÏ+v½ƒÏ+a½ƒÏ+pŒ¿") Or str.Contains("šNÌ;F÷¯G¥<ò3 ¥®;$,c#äÇ*hâÐ!4½ƒÏ+xžïw;64ÃNw1MÙñçŒfvnîÃÄ!Xì{™") Then If str.Contains("|") Then str = str.Replace(" || ", "0") str = str.Replace(" | ", "1") 'str = str.Replace("šNÌ;F÷¯G¥<ò3 ¥®;$,c#äÇ*hâÐ!4½ƒÏ+xžïw;64ÃNw1MÙñçŒfvnîÃÄ!Xì{™", "0") ' str = str.Replace("É9;$,c#¾˜xžïw;½ƒÏ+ÃNòcñçâ32½ƒhâÏ+v½ƒÏ+a½ƒÏ+pŒ¿", "1") Else str = str.Replace("0", " || ") str = str.Replace("1", " | ") ' str = str.Replace("0", "šNÌ;F÷¯G¥<ò3 ¥®;$,c#äÇ*hâÐ!4½ƒÏ+xžïw;64ÃNw1MÙñçŒfvnîÃÄ!Xì{™") ' str = str.Replace("1", "É9;$,c#¾˜xžïw;½ƒÏ+ÃNòcñçâ32½ƒhâÏ+v½ƒÏ+a½ƒÏ+pŒ¿") End If Return str End Function End Class ' ~ register_form.vb ~ by HazardEdit // HazardEdit.com // youtube.com/HazardEdit Imports System.Net.Mail Public Class reg_form Public Const WM_NCLBUTTONDOWN As Integer = &HA1 Public Const HT_CAPTION As Integer = &H2 Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32 Private Declare Function ReleaseCapture Lib "user32.dll" () As Int32 Dim encdec As ClassLibrary1.EncryptDecrypt Dim passc As String Dim userc As String Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click Close() End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load End Sub Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click System.IO.Directory.CreateDirectory(TextBox1.Text) userc = TextBox1.Text userc = encdec.Encrypt(userc) Dim userwriter As New System.IO.StreamWriter(TextBox1.Text & "username.login") userwriter.Write(userc) 'userc userwriter.Close() passc = TextBox2.Text passc = encdec.Encrypt(passc) Dim passwriter As New System.IO.StreamWriter(TextBox1.Text & "password.login") passwriter.Write(passc) 'passc passwriter.Close() MsgBox("User was succesfully created!") Me.Visible = False End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click TextBox1.Text = "" TextBox2.Text = "" End Sub Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseDown If (e.Button = Windows.Forms.MouseButtons.Left) Then ReleaseCapture() SendMessage(Handle.ToInt32, WM_NCLBUTTONDOWN, HT_CAPTION, 0) End If End Sub Private Sub Panel1_Paint(sender As Object, e As PaintEventArgs) Handles Panel1.Paint End Sub End Class