Search the Community
Showing results for tags 'string if then else'.
-
I have coded a snippet to ensure that my software runs only on systems that i have registered in my database and for that use the unique hardware id and then carry out conditional statements to check if the stored hardware id and the current hardware id of the system match. but the following code still says that the strings are not equal even when the strings clearly appear equal #include <Crypt.au3> #include <date.au3> #include <MsgBoxConstants.au3> #include <APIDiagConstants.au3> #include <WinAPIDiag.au3> Global $EncryptionPassword = InputBox("Enter the Password", "Enter the Encryption Password ", "", "",- 1, -1) Global $CustomerID=InputBox("Enter the Customer ID", "Enter the Customer ID to Generate Key for ", "", "",- 1, -1) Global $Expiry_Date2 = InputBox("Enter Desired Expiry Date", "Enter the Desired Expiry Date to generate a key for ", "YYYY/MM/DD", "",- 1, -1) ;~ Global $EncryptionPassword="cybertech83" Global $hardware1 = InputBox("Enter Desired Hardware ID", "Enter the Hardware ID to generate a key for ", "{XXXX-XXXX-XXXX-XXXX-XXXX}", "",- 1, -1) ;~ Global $hardware1 = _WinAPI_UniqueHardwareID($UHID_All) & @CRLF Global $EncryptData=$hardware1&"//"&$Expiry_Date2 MsgBox($MB_SYSTEMMODAL, 'Data to be Encrypte is -', $EncryptData) Global $Encrypted = StringEncrypt($EncryptData, $EncryptionPassword) MsgBox($MB_SYSTEMMODAL, 'Generated Key is -', $Encrypted) DirRemove($CustomerID) DirCreate($CustomerID) FileDelete($CustomerID) FileWrite($CustomerID&"\"&$CustomerID&".ct83",$Encrypted) Func StringEncrypt($sData, $sPassword) _Crypt_Startup() ; Start the Crypt library. Local $sReturn = '' $sReturn = _Crypt_EncryptData($sData, $sPassword, $CALG_AES_256) _Crypt_Shutdown() ; Shutdown the Crypt library. Return $sReturn EndFunc ;==>StringEncrypt this is the first part of the code which helps me(developer) to create encrypted files which contain the hardware id and the expiry date of the software the second part is used to run on the client pc to check if the computer has the hardware id that i have registered and created the files for #include <Crypt.au3> #include <date.au3> #include <MsgBoxConstants.au3> #include <APIDiagConstants.au3> #include <WinAPIDiag.au3> #include <File.au3> #include <MsgBoxConstants.au3> #include <StringConstants.au3> Global $Decrypted Global $Decrypted_Config Global $CustomerID=InputBox("Enter the Customer ID", "Enter the Customer ID Validate the Key ", "", "",- 1, -1) If Not _FileReadToArray($CustomerID&"\"&$CustomerID&".ct83", $Decrypted_Config, 0) Then MsgBox($MB_SYSTEMMODAL, "", "There was an error Reading the 'CustomerID Configuration File'! Please Try again! Using the CustomerID supplied to you") EndIf Global $Decrypted_1 = _ArrayToString($Decrypted_Config) $Encrypted=$Decrypted_1 Global $Decrypted = StringEncrypt(False, $Encrypted,'cybertech83') ; Display the decrypted text. MsgBox($MB_SYSTEMMODAL, '', $Decrypted) Func StringEncrypt($bEncrypt, $sData, $sPassword) _Crypt_Startup() ; Start the Crypt library. Local $sReturn = '' If $bEncrypt Then ; If the flag is set to True then encrypt, otherwise decrypt. $sReturn = _Crypt_EncryptData($sData, $sPassword, $CALG_AES_256) Else $sReturn = BinaryToString(_Crypt_DecryptData($sData, $sPassword, $CALG_AES_256)) EndIf _Crypt_Shutdown() ; Shutdown the Crypt library. Return $sReturn EndFunc ;==>StringEncrypt CheckExpiry() Func CheckExpiry() Global $Decrypted_Var2 = StringSplit($Decrypted, '//', $STR_ENTIRESPLIT) Global $HardwareID2= $Decrypted_Var2[1] Global $Expiry_Date= $Decrypted_Var2[2] Global $Decrypted_Var23 = StringSplit($Expiry_Date, '/', $STR_ENTIRESPLIT) Global $year= Number($Decrypted_Var23[1]) Global $month= Number($Decrypted_Var23[2]) Global $day= Number($Decrypted_Var23[3]) MsgBox(0,"Expiry Date","The Expiry Date is "&$day&"/"&$month&"/"&$year) $expdate = Floor(_DateToDayValue($year,$month,$day)) If (Floor(_DateToDayValue(@YEAR, @MON, @MDAY)) > $expdate) Then MsgBox(0, "Error", "License has expired") Exit Else MsgBox(0,"Success!","This is a licensed Copy") EndIf EndFunc CheckHardwareID() Func CheckHardwareID() $hardware_Current = _WinAPI_UniqueHardwareID($UHID_All) & @CRLF Global $HardwareID_Config FileWrite("HardwareID.txt",$hardware_Current) If Not _FileReadToArray("HardwareID.txt", $HardwareID_Config, 0) Then MsgBox($MB_SYSTEMMODAL, "", "There was an error Reading the 'CustomerID Configuration File'! Please Try again! Using the CustomerID supplied to you") EndIf Global $hardware_Current = _ArrayToString($HardwareID_Config) Global $HardwareID2= $Decrypted_Var2[1] MsgBox(0,"",$HardwareID2) MsgBox(0,"",$hardware_Current) ;~ #cs if not ($hardware_Current=$HardwareID2) then ;~ If $hardware_Current=$HardwareID2 Then MsgBox(0,"","License is Not Approved for this Machine") Else MsgBox(0,"","License is Approved for this Machine") EndIf EndFunc ;~ #ce Sorry if the the language is too jumbly bt i guess the code is pretty simple and clear. Pls help #noob here\ PS. in short this is something similar to a stackoverflow thread http://stackoverflow.com/questions/25387378/autoit-if-string-not-equal-doesnt-work-the-way-i-expect still i fail to solve the problem