I create a project encrypt and decrypt data in vb.net
how to use this code as a function please help it is work only on a textbox
i want to send a string value then return encrypt value and when i send encrypt value then send me decrypt value.
What I have tried:
Private arLetterChars() As Char = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 "
Private arEncryptedChars() As Char = "******************************************************"
' encrypt.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button4.Click
With TextBox1
For Each myTextBoxChar As Char In .Text '// loop thru TextBox, one char. at a time.
For i As Integer = 0 To arLetterChars.Length - 1 '// loop thru all letters in the Array.
'// if TextBox char ='s the char in your Array, replace the TextBox char with the same #'ed Array char of the Encrypted letters.
If myTextBoxChar = arLetterChars(i) Then .Text = .Text.Replace(myTextBoxChar, arEncryptedChars(i))
Next
Next
End With
End Sub
'decrypt.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
With TextBox1
For Each myTextBoxChar As Char In .Text '// loop thru TextBox, one char. at a time.
For i As Integer = 0 To arEncryptedChars.Length - 1 '// loop thru all Encrypted char.s in the Array.
'// if TextBox char ='s the char in your Array, replace the TextBox char with the same #'ed Array char of the Letters.
If myTextBoxChar = arEncryptedChars(i) Then .Text = .Text.Replace(myTextBoxChar, arLetterChars(i))
Next
Next
End With
End Sub