Files
EDOKA_Tools/Coldstrt/Backup/Coldstrt/Crypto.vb
2020-10-21 10:43:18 +02:00

47 lines
1.6 KiB
VB.net

Module Crypto
Public Function EncryptText(ByVal strText As String, ByVal strPwd As String)
Dim i As Integer, c As Integer
Dim strBuff As String
strBuff = ""
Try
strPwd = UCase$(strPwd)
If Len(strPwd) Then
For i = 1 To Len(strText)
c = Asc(Mid$(strText, i, 1))
c = c + Asc(Mid$(strPwd, (i Mod Len(strPwd)) + 1, 1))
strBuff = strBuff & Chr(c And &HFF)
Next i
Else
strBuff = strText
End If
EncryptText = strBuff
Catch ex As Exception
Console.WriteLine("Fehler beim Verschlüsseln")
Console.WriteLine("Error: " + ex.Message)
Return strBuff
End Try
End Function
Public Function DecryptText(ByVal strText As String, ByVal strPwd As String)
Dim i As Integer, c As Integer
Dim strBuff As String
strBuff = ""
Try
strPwd = UCase$(strPwd)
If Len(strPwd) Then
For i = 1 To Len(strText)
c = Asc(Mid$(strText, i, 1))
c = c - Asc(Mid$(strPwd, (i Mod Len(strPwd)) + 1, 1))
strBuff = strBuff & Chr(c And &HFF)
Next i
Else
strBuff = strText
End If
DecryptText = strBuff
Catch ex As Exception
Console.WriteLine("Fehler beim Entschlüsseln")
Console.WriteLine("Error: " + ex.Message)
Return strBuff
End Try
End Function
End Module