Initial
This commit is contained in:
50
Common/Crypto.vb
Normal file
50
Common/Crypto.vb
Normal file
@@ -0,0 +1,50 @@
|
||||
'''<summary>Diese klasse beinhaltet Methoden welche für den Kryptografischen Teil im EDOKA verwendet werden</summary>
|
||||
Public Class Crypto
|
||||
|
||||
Const CRYPTO_PASSWORD As String = "HutterundMueller"
|
||||
|
||||
'''<summary>Verschlüsselt einen Text mit dem angegebenen Passwort</summary>
|
||||
'''<param name="strText">Zu verschlüsselnder Text</param>
|
||||
'''<includesource>yes</includesource>
|
||||
Public Shared Function EncryptText(ByVal strText As String)
|
||||
Dim i As Integer, c As Integer
|
||||
Dim strBuff As String
|
||||
Dim strPwd As String = CRYPTO_PASSWORD
|
||||
|
||||
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
|
||||
End Function
|
||||
|
||||
'''<summary>Entschlüsselt einen Text</summary>
|
||||
'''<param name="strText">Zu verschlüsselnder Text</param>
|
||||
'''<includesource>yes</includesource>
|
||||
Public Shared Function DecryptText(ByVal strText As String)
|
||||
Dim i As Integer, c As Integer
|
||||
Dim strBuff As String
|
||||
Dim strPwd As String = CRYPTO_PASSWORD
|
||||
|
||||
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
|
||||
End Function
|
||||
|
||||
End Class
|
||||
|
||||
'End Namespace
|
||||
Reference in New Issue
Block a user