Post by Gucky_87 » 11 Jul 2014, 12:20
Soooooooo
Hab die letzten Tage an den einzelnen Funktionen gearbietet und bis auf eine einzige (SglSignData) alle am Laufen.
Bevor sich das aber nun ins "Scripte & Funktionen" Forum stelle, könntest Du mal drüber schauen, wenn Du Zeit, Lust und Laune hast. Ich habe die entsprechenden Stellen, wie man verbessern könnte, kommentiert.
Sicher gibt es aber einige Stellen, die ich übersehen habe und die vllt. noch verbesserungswürdig sind...?
Code: Select all
; This program shows how to use the SG-Lock together with AutoHotKey
; IMPORTANT NOTE:
; With the Demo Authent Key it´s impossible to read/write data from/to
; the memory or counter and/or to encrypt/decrypt data, because the
; demo locks (U2 type) don´t hav any memory to store data.
#NoEnv
#Include SglAuth.AHK
; This is the DEMO authentication code, every regular SG-Lock user gets its own unique authentication code.
AuthentCode := [0xF574D17B, 0xA94628EE, 0xF2857A8F, 0x69346B4A
,0x4136E8F2, 0x89ADC688, 0x80C2C1D4, 0xA8C6327C
,0x1A72699A, 0x574B7CA0, 0x1E8D3E98, 0xD7DEFDC5]
SGL_Init() ; Load the SGL.DLL
; Authentification with SGL.DLL (Returns 0x0000 when successful)
MsgBox, 0, SGL_Authent(), % SGL_Authent(AuthentCode)
; Read Product ID from SG-Lock
DllCall(SGLDLL . "\SglReadProductId", "UIntP", SGL_ProductID)
MsgBox, 0, SglReadProductID, Current product ID: %SGL_ProductID%
; Search for a specified SG-Lock
; ========================================================================================
; Uncomment the following six lines only if you want to use a specified
; SG-Lock product id instead of the id which was read above.
; ========================================================================================
; SGL_ProductID := 1234 ; Can be 0 ... 65535. This SG-Lock ID will be used in all following examples
; Result := DllCall(SGLDLL . "\SglSearchLock", "UInt", SGL_ProductID)
; If Result = 0
; MsgBox, 0, SglSearchLock, SG-Lock found.`nProductID: %SGL_ProductID%
; else
; MsgBox, 0, SglSearchLock, Specified SG-Lock product id #%SGL_ProductID% not found!`nProgram will be terminated.
; ########################################################################################
; Read SG-Lock configuration data
VarSetCapacity(ConfigData, 32, 0)
Addr := &ConfigData
DllCall(SGLDLL . "\SglReadConfig", "UInt", SGL_ProductID, "UInt", 0, "Ptr", &ConfigData)
Loop, 8
{
Addr := A_Index - 1
Data := NumGet(ConfigData, (A_Index - 1) * 4, "UInt")
}
SG_Lock_Type := NumGet(ConfigData, 0, "UInt") + 1
SG_Lock_Interface := NumGet(ConfigData, 4, "UInt")
SG_Lock_SoftVer := "00" . NumGet(ConfigData, 8, "UInt") & 0xFFFF
SG_Lock_SoftVer := "1." . SubStr(SG_Lock_SoftVer, StrLen(SG_Lock_SoftVer) - 1)
SG_Lock_HardVer := "00" . NumGet(ConfigData, 12, "UInt") & 0xFFFF
SG_Lock_HardVer := "1." . SubStr(SG_Lock_HardVer, StrLen(SG_Lock_HardVer) - 1)
SG_Lock_SerailNo := NumGet(ConfigData, 16, "UInt")
SG_Lock_MemSize := NumGet(ConfigData, 20, "UInt")
Sg_Lock_MemBytes := SG_Lock_MemSize * 4
SG_Lock_CounterNum := NumGet(ConfigData, 24, "UInt")
SG_Lock_KeyNum := NumGet(ConfigData, 28, "UInt")
MsgBox, 0, SglReadConfig, #0: Modul type: U%SG_Lock_Type%`n#1: Interface: %SG_Lock_Interface%`n#2: Software version: v%SG_Lock_SoftVer%`n#3: Hardware version: v%SG_Lock_HardVer%`n#4: Serial number: %SG_Lock_SerailNo%`n#5: Memory size: %SG_Lock_MemSize% Cells [%SG_Lock_MemBytes% Byte]`n#6: Number of counters: %SG_Lock_CounterNum%`n#7: Number of 128 bit keys: %SG_Lock_KeyNum%
; Read serial number from SG-Lock
DllCall(SGLDLL . "\SglReadSerialNumber", "UInt", SGL_ProductID, "UIntP", SerialNumber)
MsgBox, 0, SglReadSerialNumber, Serial no: %SerialNumber%
; ########################################################################################
; Write value into memory of SG-Lock
Addr := 0
Random, WriteValue, 10000000000 99999999999
DllCall(SGLDLL . "\SglWriteData", "UInt", SGL_ProductID, "UInt", Addr, "UInt", 1, "UIntP", WriteValue)
MsgBox, 0, SglWriteData, Write to address #%Addr%: %WriteValue%
; Read memory value from SG-Lock
Addr := 0
DllCall(SGLDLL . "\SglReadData", "UInt", SGL_ProductID, "UInt", Addr, "UInt", 1, "UIntP", ReadValue)
MsgBox, 0, SglReadData, Read from address #%Addr%: %ReadValue%
; ########################################################################################
; Write counter value into counter memory of SG-Lock
CountNum := 5
Random, CountWrite, 10000000000, 99999999999
DllCall(SGLDLL . "\SglWriteCounter", "UInt", SGL_ProductID, "UInt", CountNum, "UInt", CountWrite)
MsgBox, 0, SglWriteCounter, Write to counter #%CountNum%: %CountWrite%
; Read counter value from SG-Lock
CountNum := 5
DllCall(SGLDLL . "\SglReadCounter", "UInt", SGL_ProductID, "UInt", CountNum, "UIntP", CountRead)
MsgBox, 0, SglReadCounter, Read from counter #%CountNum%: %CountRead%
; ########################################################################################
; Write 128 Bit key to SG-Lock
VarSetCapacity(NewKey, 16, 0)
KeyNum := 0
Key := [Dec2Hex(SGL_Rand()), Dec2Hex(SGL_Rand()), Dec2Hex(SGL_Rand()), Dec2Hex(SGL_Rand())]
Addr := &NewKey
Clipboard := Key[1] . " " . Key[2] . " " . Key[3] . " " . Key[4]
Loop, 4
Addr := NumPut(Key[A_Index], Addr + 0, "UInt")
Result := DllCall(SGLDLL . "\SglWriteKey", "UInt", SGL_ProductID, "UInt", KeyNum, "Ptr", &NewKey)
If Result = 0
MsgBox, 0, SglWriteKey, % Key[1] . " " . Key[2] . " " . Key[3] . " " . Key[4] . "`nfor key #" . KeyNum . " successfully stored and copied to clipboard."
else
MsgBox, 0, SglWriteKey, Unable to store key #%KeyNum%!`nError: %Result%
; ########################################################################################
; Encrypt Data
KeyNum := 0 ; Which key should be used?
Mode := 0 ; 0 = Encrypt | 1 = Decrypt
BlockCnt := 3 ; Number of crypted data blocks
VarSetCapacity(DataBlock, BlockCnt * 8, 0)
Data := [0x11111111, 0x22222222, 0x33333333, 0x44444444, 0x55555555, 0x66666666] ; Datablock to encrypt
Addr := &DataBlock
Loop, % BlockCnt * 2
Addr := NumPut(Data[A_Index], Addr + 0, "UInt")
Result := DllCall(SGLDLL . "\SglCryptLock", "UInt", SGL_ProductID, "UInt", KeyNum, "UInt", Mode, "UInt", BlockCnt, "Ptr", &DataBlock)
If Result = 0
{
; #### Das hier könnte man vllt mit einem Loop besser machen?
; #### Allerdings funktioniert das Golgende bei mir nicht.
; #### Ich bekomme in einer MagBos leere Werte zurück?!
; #### Loop, % BlockCnt * 2
; #### {
; #### Enc%A_Index% := NumGet(DataBlock, (A_Index - 1) * 4, "UInt")
; #### }
Enc1 := Dec2Hex(NumGet(DataBlock, 0, "UInt"))
Enc2 := Dec2Hex(NumGet(DataBlock, 4, "UInt"))
Enc3 := Dec2Hex(NumGet(DataBlock, 8, "UInt"))
Enc4 := Dec2Hex(NumGet(DataBlock, 12, "UInt"))
Enc5 := Dec2Hex(NumGet(DataBlock, 16, "UInt"))
Enc6 := Dec2Hex(NumGet(DataBlock, 20, "UInt"))
MsgBox, 0, SglCryptLock (encrypt), % "Encryption of " . BlockCnt . " data blocks successful.`nUsed encryption key: #" . KeyNum . "`n`nOriginal data:`t`t Encrypted data:`n" . Dec2Hex(Data[1]) . " `t==>`t " . Enc1 . "`n" . Dec2Hex(Data[2]) . " `t==>`t " . Enc2 . "`n" . Dec2Hex(Data[3]) . " `t==>`t " . Enc3 . "`n" . Dec2Hex(Data[4]) . " `t==>`t " . Enc4 . "`n" . Dec2Hex(Data[5]) . " `t==>`t " . Enc5 . "`n" . Dec2Hex(Data[6]) . " `t==>`t " . Enc6
}
else
MsgBox, 0, SglCryptLock, Encryption failed!`nErrorcode: #%Result%
; ########################################################################################
; Decrypt Data
KeyNum := 0 ; Which key should be used?
Mode := 1 ; 0 = Encrypt | 1 = Decrypt
BlockCnt := 3 ; Number of crypted data blocks
VarSetCapacity(DataDec, BlockCnt * 8, 0)
EncData := [Enc1, Enc2, Enc3, Enc4, Enc5, Enc6] ; Datablock to encrypt (filled with values we just have encrypted above)
Addr := &DataDec
Loop, % BlockCnt * 2
Addr := NumPut(EncData[A_Index], Addr + 0, "UInt")
Result := DllCall(SGLDLL . "\SglCryptLock", "UInt", SGL_ProductID, "UInt", KeyNum, "UInt", Mode, "UInt", BlockCnt, "Ptr", &DataDec)
If Result = 0
{
; #### Hier ist es ebenso, wie in dem Teil oben. Im Loop klappt das
; #### Auslesen nicht?!
; #### Loop, % BlockCnt * 2
; #### {
; #### Dec%A_Index% := NumGet(DataDec, (A_Index - 1) * 4, "UInt")
; #### }
SetFormat, Integer, H
Dec1 := Dec2Hex(NumGet(DataDec, 0, "UInt"))
Dec2 := Dec2Hex(NumGet(DataDec, 4, "UInt"))
Dec3 := Dec2Hex(NumGet(DataDec, 8, "UInt"))
Dec4 := Dec2Hex(NumGet(DataDec, 12, "UInt"))
Dec5 := Dec2Hex(NumGet(DataDec, 16, "UInt"))
Dec6 := Dec2Hex(NumGet(DataDec, 20, "UInt"))
MsgBox, 0, SglCryptLock, % "Decryption of " . BlockCnt . " data blocks successful.`nUsed decryption key: #" . KeyNum . "`n`nEncrypted data:`t`t Decrypted data:`n" . Dec2Hex(EncData[1]) . " `t==>`t " . Dec1 . "`n" . Dec2Hex(EncData[2]) . " `t==>`t " . Dec2 . "`n" . Dec2Hex(EncData[3]) . " `t==>`t " . Dec3 . "`n" . Dec2Hex(EncData[4]) . " `t==>`t " . Dec4 . "`n" . Dec2Hex(EncData[5]) . " `t==>`t " . Dec5 . "`n" . Dec2Hex(EncData[6]) . " `t==>`t " . Dec6
}
else
MsgBox, 0, SglCryptLock (decrypt), Decryption failed!`nErrorcode: #%Result%
; ########################################################################################
ExitApp
; ################################# Subroutnes #########################################
; Converts a decimal value to hex
; Example: x := Dec2Hex(10) will return "0A".
Dec2Hex(h)
{
format = %A_FormatInteger%
SetFormat, Integer, hex
H += 0
SetFormat, Integer, d
StringLeft, C, H, 2
If C = 0x
{
L := StrLen(h) -2
StringRight, h, h, L
}
If StrLen(h) < 2
H = 0%h%
StringUpper, h, h
SetFormat Integer, %format%
Return, "0x" . h
}
Außerdem arbeite ich an einem Tool, das quasi die SGLMGR.EXE verkörpert, aber
evtl. noch ein paar Dinge mehr, bzw. anders machen soll. Das GUI dafür steht schon fast. Wird natürlich dann später auch unter 'Scripte & Funktionen' veröffentlicht.
Auch würde ich gern die einzelnen Programmteile noch si umgestalten, dass Funktionen daraus werden (z.B. Sgl_CryptLock(InputText, KeyNumber) ).
Das aber erst dann, wenn der bisherhige Code 'sauber' ist.
Gucky.
Soooooooo ;)
Hab die letzten Tage an den einzelnen Funktionen gearbietet und bis auf eine einzige (SglSignData) alle am Laufen.
Bevor sich das aber nun ins "Scripte & Funktionen" Forum stelle, könntest Du mal drüber schauen, wenn Du Zeit, Lust und Laune hast. Ich habe die entsprechenden Stellen, wie man verbessern könnte, kommentiert.
Sicher gibt es aber einige Stellen, die ich übersehen habe und die vllt. noch verbesserungswürdig sind...?
[code]
; This program shows how to use the SG-Lock together with AutoHotKey
; IMPORTANT NOTE:
; With the Demo Authent Key it´s impossible to read/write data from/to
; the memory or counter and/or to encrypt/decrypt data, because the
; demo locks (U2 type) don´t hav any memory to store data.
#NoEnv
#Include SglAuth.AHK
; This is the DEMO authentication code, every regular SG-Lock user gets its own unique authentication code.
AuthentCode := [0xF574D17B, 0xA94628EE, 0xF2857A8F, 0x69346B4A
,0x4136E8F2, 0x89ADC688, 0x80C2C1D4, 0xA8C6327C
,0x1A72699A, 0x574B7CA0, 0x1E8D3E98, 0xD7DEFDC5]
SGL_Init() ; Load the SGL.DLL
; Authentification with SGL.DLL (Returns 0x0000 when successful)
MsgBox, 0, SGL_Authent(), % SGL_Authent(AuthentCode)
; Read Product ID from SG-Lock
DllCall(SGLDLL . "\SglReadProductId", "UIntP", SGL_ProductID)
MsgBox, 0, SglReadProductID, Current product ID: %SGL_ProductID%
; Search for a specified SG-Lock
; ========================================================================================
; Uncomment the following six lines only if you want to use a specified
; SG-Lock product id instead of the id which was read above.
; ========================================================================================
; SGL_ProductID := 1234 ; Can be 0 ... 65535. This SG-Lock ID will be used in all following examples
; Result := DllCall(SGLDLL . "\SglSearchLock", "UInt", SGL_ProductID)
; If Result = 0
; MsgBox, 0, SglSearchLock, SG-Lock found.`nProductID: %SGL_ProductID%
; else
; MsgBox, 0, SglSearchLock, Specified SG-Lock product id #%SGL_ProductID% not found!`nProgram will be terminated.
; ########################################################################################
; Read SG-Lock configuration data
VarSetCapacity(ConfigData, 32, 0)
Addr := &ConfigData
DllCall(SGLDLL . "\SglReadConfig", "UInt", SGL_ProductID, "UInt", 0, "Ptr", &ConfigData)
Loop, 8
{
Addr := A_Index - 1
Data := NumGet(ConfigData, (A_Index - 1) * 4, "UInt")
}
SG_Lock_Type := NumGet(ConfigData, 0, "UInt") + 1
SG_Lock_Interface := NumGet(ConfigData, 4, "UInt")
SG_Lock_SoftVer := "00" . NumGet(ConfigData, 8, "UInt") & 0xFFFF
SG_Lock_SoftVer := "1." . SubStr(SG_Lock_SoftVer, StrLen(SG_Lock_SoftVer) - 1)
SG_Lock_HardVer := "00" . NumGet(ConfigData, 12, "UInt") & 0xFFFF
SG_Lock_HardVer := "1." . SubStr(SG_Lock_HardVer, StrLen(SG_Lock_HardVer) - 1)
SG_Lock_SerailNo := NumGet(ConfigData, 16, "UInt")
SG_Lock_MemSize := NumGet(ConfigData, 20, "UInt")
Sg_Lock_MemBytes := SG_Lock_MemSize * 4
SG_Lock_CounterNum := NumGet(ConfigData, 24, "UInt")
SG_Lock_KeyNum := NumGet(ConfigData, 28, "UInt")
MsgBox, 0, SglReadConfig, #0: Modul type: U%SG_Lock_Type%`n#1: Interface: %SG_Lock_Interface%`n#2: Software version: v%SG_Lock_SoftVer%`n#3: Hardware version: v%SG_Lock_HardVer%`n#4: Serial number: %SG_Lock_SerailNo%`n#5: Memory size: %SG_Lock_MemSize% Cells [%SG_Lock_MemBytes% Byte]`n#6: Number of counters: %SG_Lock_CounterNum%`n#7: Number of 128 bit keys: %SG_Lock_KeyNum%
; Read serial number from SG-Lock
DllCall(SGLDLL . "\SglReadSerialNumber", "UInt", SGL_ProductID, "UIntP", SerialNumber)
MsgBox, 0, SglReadSerialNumber, Serial no: %SerialNumber%
; ########################################################################################
; Write value into memory of SG-Lock
Addr := 0
Random, WriteValue, 10000000000 99999999999
DllCall(SGLDLL . "\SglWriteData", "UInt", SGL_ProductID, "UInt", Addr, "UInt", 1, "UIntP", WriteValue)
MsgBox, 0, SglWriteData, Write to address #%Addr%: %WriteValue%
; Read memory value from SG-Lock
Addr := 0
DllCall(SGLDLL . "\SglReadData", "UInt", SGL_ProductID, "UInt", Addr, "UInt", 1, "UIntP", ReadValue)
MsgBox, 0, SglReadData, Read from address #%Addr%: %ReadValue%
; ########################################################################################
; Write counter value into counter memory of SG-Lock
CountNum := 5
Random, CountWrite, 10000000000, 99999999999
DllCall(SGLDLL . "\SglWriteCounter", "UInt", SGL_ProductID, "UInt", CountNum, "UInt", CountWrite)
MsgBox, 0, SglWriteCounter, Write to counter #%CountNum%: %CountWrite%
; Read counter value from SG-Lock
CountNum := 5
DllCall(SGLDLL . "\SglReadCounter", "UInt", SGL_ProductID, "UInt", CountNum, "UIntP", CountRead)
MsgBox, 0, SglReadCounter, Read from counter #%CountNum%: %CountRead%
; ########################################################################################
; Write 128 Bit key to SG-Lock
VarSetCapacity(NewKey, 16, 0)
KeyNum := 0
Key := [Dec2Hex(SGL_Rand()), Dec2Hex(SGL_Rand()), Dec2Hex(SGL_Rand()), Dec2Hex(SGL_Rand())]
Addr := &NewKey
Clipboard := Key[1] . " " . Key[2] . " " . Key[3] . " " . Key[4]
Loop, 4
Addr := NumPut(Key[A_Index], Addr + 0, "UInt")
Result := DllCall(SGLDLL . "\SglWriteKey", "UInt", SGL_ProductID, "UInt", KeyNum, "Ptr", &NewKey)
If Result = 0
MsgBox, 0, SglWriteKey, % Key[1] . " " . Key[2] . " " . Key[3] . " " . Key[4] . "`nfor key #" . KeyNum . " successfully stored and copied to clipboard."
else
MsgBox, 0, SglWriteKey, Unable to store key #%KeyNum%!`nError: %Result%
; ########################################################################################
; Encrypt Data
KeyNum := 0 ; Which key should be used?
Mode := 0 ; 0 = Encrypt | 1 = Decrypt
BlockCnt := 3 ; Number of crypted data blocks
VarSetCapacity(DataBlock, BlockCnt * 8, 0)
Data := [0x11111111, 0x22222222, 0x33333333, 0x44444444, 0x55555555, 0x66666666] ; Datablock to encrypt
Addr := &DataBlock
Loop, % BlockCnt * 2
Addr := NumPut(Data[A_Index], Addr + 0, "UInt")
Result := DllCall(SGLDLL . "\SglCryptLock", "UInt", SGL_ProductID, "UInt", KeyNum, "UInt", Mode, "UInt", BlockCnt, "Ptr", &DataBlock)
If Result = 0
{
; #### Das hier könnte man vllt mit einem Loop besser machen?
; #### Allerdings funktioniert das Golgende bei mir nicht.
; #### Ich bekomme in einer MagBos leere Werte zurück?!
; #### Loop, % BlockCnt * 2
; #### {
; #### Enc%A_Index% := NumGet(DataBlock, (A_Index - 1) * 4, "UInt")
; #### }
Enc1 := Dec2Hex(NumGet(DataBlock, 0, "UInt"))
Enc2 := Dec2Hex(NumGet(DataBlock, 4, "UInt"))
Enc3 := Dec2Hex(NumGet(DataBlock, 8, "UInt"))
Enc4 := Dec2Hex(NumGet(DataBlock, 12, "UInt"))
Enc5 := Dec2Hex(NumGet(DataBlock, 16, "UInt"))
Enc6 := Dec2Hex(NumGet(DataBlock, 20, "UInt"))
MsgBox, 0, SglCryptLock (encrypt), % "Encryption of " . BlockCnt . " data blocks successful.`nUsed encryption key: #" . KeyNum . "`n`nOriginal data:`t`t Encrypted data:`n" . Dec2Hex(Data[1]) . " `t==>`t " . Enc1 . "`n" . Dec2Hex(Data[2]) . " `t==>`t " . Enc2 . "`n" . Dec2Hex(Data[3]) . " `t==>`t " . Enc3 . "`n" . Dec2Hex(Data[4]) . " `t==>`t " . Enc4 . "`n" . Dec2Hex(Data[5]) . " `t==>`t " . Enc5 . "`n" . Dec2Hex(Data[6]) . " `t==>`t " . Enc6
}
else
MsgBox, 0, SglCryptLock, Encryption failed!`nErrorcode: #%Result%
; ########################################################################################
; Decrypt Data
KeyNum := 0 ; Which key should be used?
Mode := 1 ; 0 = Encrypt | 1 = Decrypt
BlockCnt := 3 ; Number of crypted data blocks
VarSetCapacity(DataDec, BlockCnt * 8, 0)
EncData := [Enc1, Enc2, Enc3, Enc4, Enc5, Enc6] ; Datablock to encrypt (filled with values we just have encrypted above)
Addr := &DataDec
Loop, % BlockCnt * 2
Addr := NumPut(EncData[A_Index], Addr + 0, "UInt")
Result := DllCall(SGLDLL . "\SglCryptLock", "UInt", SGL_ProductID, "UInt", KeyNum, "UInt", Mode, "UInt", BlockCnt, "Ptr", &DataDec)
If Result = 0
{
; #### Hier ist es ebenso, wie in dem Teil oben. Im Loop klappt das
; #### Auslesen nicht?!
; #### Loop, % BlockCnt * 2
; #### {
; #### Dec%A_Index% := NumGet(DataDec, (A_Index - 1) * 4, "UInt")
; #### }
SetFormat, Integer, H
Dec1 := Dec2Hex(NumGet(DataDec, 0, "UInt"))
Dec2 := Dec2Hex(NumGet(DataDec, 4, "UInt"))
Dec3 := Dec2Hex(NumGet(DataDec, 8, "UInt"))
Dec4 := Dec2Hex(NumGet(DataDec, 12, "UInt"))
Dec5 := Dec2Hex(NumGet(DataDec, 16, "UInt"))
Dec6 := Dec2Hex(NumGet(DataDec, 20, "UInt"))
MsgBox, 0, SglCryptLock, % "Decryption of " . BlockCnt . " data blocks successful.`nUsed decryption key: #" . KeyNum . "`n`nEncrypted data:`t`t Decrypted data:`n" . Dec2Hex(EncData[1]) . " `t==>`t " . Dec1 . "`n" . Dec2Hex(EncData[2]) . " `t==>`t " . Dec2 . "`n" . Dec2Hex(EncData[3]) . " `t==>`t " . Dec3 . "`n" . Dec2Hex(EncData[4]) . " `t==>`t " . Dec4 . "`n" . Dec2Hex(EncData[5]) . " `t==>`t " . Dec5 . "`n" . Dec2Hex(EncData[6]) . " `t==>`t " . Dec6
}
else
MsgBox, 0, SglCryptLock (decrypt), Decryption failed!`nErrorcode: #%Result%
; ########################################################################################
ExitApp
; ################################# Subroutnes #########################################
; Converts a decimal value to hex
; Example: x := Dec2Hex(10) will return "0A".
Dec2Hex(h)
{
format = %A_FormatInteger%
SetFormat, Integer, hex
H += 0
SetFormat, Integer, d
StringLeft, C, H, 2
If C = 0x
{
L := StrLen(h) -2
StringRight, h, h, L
}
If StrLen(h) < 2
H = 0%h%
StringUpper, h, h
SetFormat Integer, %format%
Return, "0x" . h
}
[/code]
Außerdem arbeite ich an einem Tool, das quasi die SGLMGR.EXE verkörpert, aber
evtl. noch ein paar Dinge mehr, bzw. anders machen soll. Das GUI dafür steht schon fast. Wird natürlich dann später auch unter 'Scripte & Funktionen' veröffentlicht.
Auch würde ich gern die einzelnen Programmteile noch si umgestalten, dass Funktionen daraus werden (z.B. Sgl_CryptLock(InputText, KeyNumber) ).
Das aber erst dann, wenn der bisherhige Code 'sauber' ist.
Gucky.