MiserableMad
Active member
- Joined
- Feb 2, 2007
- Messages
- 25
- Programming Experience
- Beginner
NM got it...is this good for SIMPLE text encryption?
VB.NET:
#Region "Encrypt/Decrypt"
Private Sub btnSimpleEncrypt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSimpleEncrypt.Click
Dim current As String
Dim intCurrSTR As Integer
Dim random As New Random
rndnum = random.Next(100, 399)
counter = 1
txt2.Text = ""
setASC()
If validatePSW() = False Then
MsgBox("Password error", , Me.Text)
Exit Sub
End If
Dim pswName As String
pswName = one.Text & two.Text & three.Text & four.Text & five.Text & six.Text
Dim changeChar, changeTextAPP As String
changeTextAPP = pswName & txt1.Text
For Each character As Char In changeTextAPP
changeChar &= changecurrent(character)
Next
For Each character As Char In changeChar
intCurrSTR = Asc(character)
current = Str(intCurrSTR) + setnum() + rndnum
txt2.Text &= current
Next
txt2.Text = rndnum.ToString & txt2.Text
End Sub
Private Sub btnSimpleDecrypt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSimpleDecrypt.Click
counter = 1
If validatePSW() = False Then
MsgBox("Password error", , Me.Text)
Exit Sub
End If
setASC()
On Error Resume Next
Dim current, change, changed, final, rdnNum As String
Dim intCurrSTR, countPlace, intRndNum As Integer
txt2.Text = String.Empty
rdnNum = txt1.Text.Substring(0, 3)
txt1.Text = txt1.Text.Remove(0, 3)
For countPlace = 0 To txt1.Text.Length Step 3
change = txt1.Text.Substring(countPlace, 3)
intCurrSTR = Val(change)
current = Str(intCurrSTR) - setnum() - Val(rdnNum)
final &= Chr(current)
Next
For Each character As Char In final
txt2.Text &= changecurrent(character)
Next
Dim getchar, currPSW As String
currPSW = one.Text & two.Text & three.Text & four.Text & five.Text & six.Text
getchar = txt2.Text.Substring(0, 6)
If getchar <> currPSW Then
txt2.Text = ""
Else
txt2.Text = txt2.Text.Remove(0, 6)
End If
txt1.Text = rdnNum & txt1.Text
End Sub
Function validatePSW() As Boolean
validatePSW = True
If Not (one.Text.ToLower >= "a" Or one.Text >= "0") Then Return False
If Not (two.Text.ToLower >= "a" Or two.Text >= "0") Then Return False
If Not (three.Text.ToLower >= "a" Or three.Text >= "0") Then Return False
If Not (four.Text.ToLower >= "a" Or four.Text >= "0") Then Return False
If Not (five.Text.ToLower >= "a" Or five.Text >= "0") Then Return False
If Not (six.Text.ToLower >= "a" Or six.Text >= "0") Then Return False
End Function
Sub setASC()
intone = Asc(one.Text)
inttwo = Asc(two.Text)
intthree = Asc(three.Text)
intfour = Asc(four.Text)
intfive = Asc(five.Text)
intsix = Asc(six.Text)
num1 = (intone + intfive) + 129 + (rndnum / 6)
...
End Sub
Function setnum()
Dim intCurrNum As Int16
Select Case counter
Case 1
intCurrNum = num1
...
Case 20
intCurrNum = num20
counter = 0
End Select
counter += 1
Return intCurrNum
End Function
Function changecurrent(ByVal current As Char) As String
Select Case current.ToString.ToLower
Case "a"
changecurrent = "n"
...
...
Case Else
changecurrent = current
End Select
If current.ToString.ToUpper = current Then
changecurrent = changecurrent.ToString.ToUpper
End If
Return changecurrent
End Function
#End Region
Last edited: