Thema Datum  Von Nutzer Rating
Antwort
27.03.2022 19:30:00 A. Ruck
NotSolved
27.03.2022 19:51:37 ralf_b
NotSolved
28.03.2022 11:08:30 Gast41579
NotSolved
28.03.2022 12:41:37 Gast64617
NotSolved
28.03.2022 14:11:05 Trägheit
NotSolved
28.03.2022 17:33:04 A. Ruck
NotSolved
29.03.2022 07:10:03 ralf_b
NotSolved
Blau Passwortprüfung mit MD5 Hash
28.03.2022 17:52:28 A. Ruck
NotSolved

Ansicht des Beitrags:
Von:
A. Ruck
Datum:
28.03.2022 17:52:28
Views:
868
Rating: Antwort:
  Ja
Thema:
Passwortprüfung mit MD5 Hash

Da ich festgestellt habe, dass ich nur einen Teil des Programms kopiert hatte, hier nur die komplette Fassung:

 

Option Explicit

Private Declare PtrSafe Function CryptAcquireContext Lib "advapi32.dll" _
  Alias "CryptAcquireContextA" ( _
  ByRef phProv As Long, _
  ByVal pszContainer As String, _
  ByVal pszProvider As String, _
  ByVal dwProvType As Long, _
  ByVal dwFlags As Long) As Long
 
Private Declare PtrSafe Function CryptReleaseContext Lib "advapi32.dll" ( _
  ByVal hProv As Long, _
  ByVal dwFlags As Long) As Long
 
Private Declare PtrSafe Function CryptCreateHash Lib "advapi32.dll" ( _
  ByVal hProv As Long, _
  ByVal Algid As Long, _
  ByVal hKey As Long, _
  ByVal dwFlags As Long, _
  ByRef phHash As Long) As Long
 
Private Declare PtrSafe Function CryptDestroyHash Lib "advapi32.dll" ( _
  ByVal hHash As Long) As Long
 
Private Declare PtrSafe Function CryptHashData Lib "advapi32.dll" ( _
  ByVal hHash As Long, _
  pbData As Byte, _
  ByVal dwDataLen As Long, _
  ByVal dwFlags As Long) As Long
 
Private Declare PtrSafe Function CryptGetHashParam Lib "advapi32.dll" ( _
  ByVal hHash As Long, _
  ByVal dwParam As Long, _
  pbData As Any, _
  pdwDataLen As Long, _
  ByVal dwFlags As Long) As Long

Private Const ALG_CLASS_HASH As Long = (4 * 2 ^ 13)
Private Const ALG_SID_HMAC As Long = 9
Private Const ALG_SID_MD2 As Long = 1
Private Const ALG_SID_MD4 As Long = 2
Private Const ALG_SID_MD5 As Long = 3
Private Const ALG_SID_SHA As Long = 4
Private Const ALG_SID_SHA1 As Long = 4
Private Const ALG_TYPE_ANY As Long = 0
Private Const CALG_MD2 As Long = (ALG_CLASS_HASH Or ALG_TYPE_ANY Or ALG_SID_MD2)
Private Const CALG_MD4 As Long = (ALG_CLASS_HASH Or ALG_TYPE_ANY Or ALG_SID_MD4)
Private Const CALG_MD5 As Long = (ALG_CLASS_HASH Or ALG_TYPE_ANY Or ALG_SID_MD5)
Private Const CALG_SHA1 As Long = (ALG_CLASS_HASH Or ALG_TYPE_ANY Or ALG_SID_SHA1)

Enum Algorithmus
    md2 = CALG_MD2
    md4 = CALG_MD4
    md5 = CALG_MD5
    SHA1 = CALG_SHA1
End Enum

Function Crypt(Text As String, Art As Algorithmus) As String
Dim AcquireContext As Long
Dim HashHandle As Long
Dim result As Long
Dim ByteText() As Byte
Dim LängeResult As Long
Dim ByteResult() As Byte
Dim Zähler As Integer
ByteText() = StrConv(Text, vbFromUnicode)
 
result = CryptAcquireContext(AcquireContext, vbNullString, vbNullString, 1, 0)
If result = 0 And Err.LastDllError = &H80090016 Then _
    result = CryptAcquireContext(AcquireContext, vbNullString, vbNullString, 1, &H8)
 
result = CryptCreateHash(AcquireContext, Art, 0, 0, HashHandle)
 
result = CryptHashData(HashHandle, ByteText(0), Len(Text), 0)
 
result = CryptGetHashParam(HashHandle, 4, LängeResult, 4, 0)
 
ReDim ByteResult(0 To LängeResult - 1) As Byte
result = CryptGetHashParam(HashHandle, 2, ByteResult(0), LängeResult, 0)
 
For Zähler = 0 To UBound(ByteResult)
    Crypt = Crypt & Right$("0" & Hex$(ByteResult(Zähler)), 2)
Next
 
CryptDestroyHash HashHandle
CryptReleaseContext AcquireContext, 0
 
End Function

Private Sub CommandButton1_Click()
Unload Gültigkeitsprüfung
Eingabemaske.Show
End Sub

Private Sub CommandButton2_Click()
Unload Gültigkeitsprüfung
End Sub

Private Sub CommandButton3_Click()
If TextBox1.Value <> vbNullString Then
Worksheets("Tabelle1").Range("B86").Value = Crypt(TextBox1.Value, md5)
Dim result As Integer
result = StrComp(Worksheets("Tabelle1").Range("B86").Value, Worksheets("Tabelle1").Range("B84").Value, vbTextCompare)
    If result = 0 Then
    Worksheets("Tabelle1").Range("B85").Value = "x"
    Worksheets("Tabelle1").Range("B87").Value = Environ("Username")
    MsgBox "Der eingegebene Lizenzschlüssel ist korrekt."
    Unload Gültigkeitsprüfung
    Eingabemaske.Show
    Else
    MsgBox "Ungültiger Lizenzschlüssel"
    End If
Else
    MsgBox "Bitte geben Sie einen Lizenzschlüssel ein."
    
End If

End Sub

Private Sub Label1_Click()

End Sub

Private Sub UserForm_Initialize()
If Date > Worksheets("Tabelle1").Range("B82").Value Then
CommandButton1.Enabled = False
Label1.Caption = "Diese Testversion ist abgelaufen." & vbCrLf & vbCrLf & "Bitte geben Sie einen gültigen Lizenzschlüssel ein."
Else
CommandButton1.Enabled = True
Label1.Caption = "Diese Testversion ist noch bis zum " & Worksheets("Tabelle1").Range("B82").Value & " gültig." & vbCrLf & "Danach benötigen Sie einen Lizenzschlüssel."
End If

End Sub


Ihre Antwort
  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen
Thema: Name: Email:



  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen

Thema Datum  Von Nutzer Rating
Antwort
27.03.2022 19:30:00 A. Ruck
NotSolved
27.03.2022 19:51:37 ralf_b
NotSolved
28.03.2022 11:08:30 Gast41579
NotSolved
28.03.2022 12:41:37 Gast64617
NotSolved
28.03.2022 14:11:05 Trägheit
NotSolved
28.03.2022 17:33:04 A. Ruck
NotSolved
29.03.2022 07:10:03 ralf_b
NotSolved
Blau Passwortprüfung mit MD5 Hash
28.03.2022 17:52:28 A. Ruck
NotSolved