Hallo!
Ich teste mal wieder ein wenig in AutoIt. Abeer alles aus VBA kann ich nicht übersetzen. Z.B. finde ich keinen Ersatz für "For Each" und/oder verstehe ich nicht. Auch API-Ersatz und Kommandzeilen-Anweisungen habe ich noch nicht gefunden. Wie könnte man das nach AutoIt übersetzen, und wo finde ich darüber Lesestoff? Danke!
Code
Private Declare 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 Function CryptReleaseContext Lib "advapi32.dll" (ByVal hProv As Long, ByVal dwFlags As Long) As Long
Private Declare 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 Function CryptDestroyHash Lib "advapi32.dll" (ByVal hHash As Long) As Long
Private Declare Function CryptHashData Lib "advapi32.dll" (ByVal hHash As Long, pbData As Byte, ByVal dwDataLen As Long, ByVal dwFlags As Long) As Long
Private Declare 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
Public Function stringPC() As String
strSQL = "Select * from Win32_Processor"
strWMI = "winmgmts:\\.\root\cimv2"
Set oWMI = GetObject(strWMI).ExecQuery(strSQL)
For Each objItem In oWMI
stringPC = objItem.ProcessorId
Next
End Function
Public Function exchangeDigitA(sText)
Dim myDic As Object
Dim b() As Byte
Dim Ding
Dim Tmp
Set myDic = CreateObject("scripting.Dictionary")
myDic(1) = 3
myDic(4) = 6
b = StrConv(sText, vbFromUnicode)
For Each Ding In myDic
Tmp = b(Ding - 1)
b(Ding - 1) = b(myDic(Ding) - 1)
b(myDic(Ding) - 1) = Tmp
Next
exchangeDigitA = StrConv(b, vbUnicode)
End Function
Alles anzeigen
Gruß, René