Jump to content

trial


AZJIO
 Share

Recommended Posts

trial.au3

#include <Crypt.au3>

$timer = TimerInit() ; Timer to check the validation time.

Local $aLng[12]

$aLng[1] = 'Error'
$aLng[2] = 'Invalid key.' & @CRLF & 'Delete key?'
$aLng[3] = 'Program registration'
$aLng[4] = 'You use the program in trial mode. To start the program, click'
$aLng[5] = '. Register the program to hide this start dialogue.'
$aLng[6] = 'Registration'
$aLng[7] = 'Login'
$aLng[8] = 'Password'
$aLng[9] = 'Register'
$aLng[10] = 'Enter login of long not less than 5 characters.'
$aLng[11] = 'Password is missing or invalid'

; Ru
If @OSLang = 0419 Then
    $aLng[1] = 'Ошибка'
    $aLng[2] = 'Ключ неверный.' & @CRLF & 'Удалить ключ?'
    $aLng[3] = 'Регистрация программы'
    $aLng[4] = 'Вы используете программу в ознакомительном режиме. Для старта программы нажмите кнопку'
    $aLng[5] = '. Зарегистрируйте програму для скрытия этого стартового диалога.'
    $aLng[6] = 'Регистрация'
    $aLng[7] = 'Логин'
    $aLng[8] = 'Пароль'
    $aLng[9] = 'Зарегистрировать'
    $aLng[10] = 'Введите логин длинной не менее 5 символов.'
    $aLng[11] = 'Пароль отсутствует или неверный'
EndIf

_Crypt_Startup()
_Checking_Account()
_Crypt_Shutdown()

; your script starts here ..............
MsgBox(0, "Successful validation", 'Time : ' & Round(TimerDiff($timer) / 1000, 2) & ' sec')

Func _Checking_Account()
    Local $hGuiTrial, $iBtnNum[6] = [5], $vLK, $hFile, $LK, $login, $login0, $msg, $pasw, $pasw0, $registr, $Rnd, $sPassKey, $x = -40
    $sPassKey = 'GwE1rnODk3q260' ; the password for the encryption of the license key file
    $LK = @ScriptDir & '\LK.key'
    If FileExists($LK) Then ; If the file exists, check it out, otherwise output the registration dialogue
        $hFile = FileOpen($LK, 16)
        $vLK = FileRead($hFile)
        FileClose($hFile)
        $vLK = StringSplit(BinaryToString(_Crypt_DecryptData($vLK, $sPassKey, $CALG_AES_256)), @LF)
        If $vLK[0] > 1 And $vLK[2] = _GenKey($vLK[1]) Then ; If the code is correct, then exit the function, otherwise the uninstall and the withdrawal of the registration dialog
            Return
        Else
            If MsgBox(4, $aLng[1], $aLng[2]) = 6 Then FileDelete($LK)
        EndIf
    EndIf
    $hGuiTrial = GUICreate($aLng[3], 340, 220)
    $Rnd = Random(1, 5, 1)
    GUICtrlCreateLabel($aLng[4] & ' ' & $Rnd & $aLng[5], 10, 5, 325, 50)

    GUICtrlCreateGroup($aLng[6], 5, 60, 330, 110)
    GUICtrlCreateLabel($aLng[7], 10, 82, 45, 20)
    $login = GUICtrlCreateInput('', 55, 80, 265, 20)

    GUICtrlCreateLabel($aLng[8], 10, 112, 45, 20)
    $pasw = GUICtrlCreateInput('', 55, 110, 265, 20)
    $registr = GUICtrlCreateButton($aLng[9], 210, 136, 110, 25)
    GUISetFont(13, 700, -1, 'Arial')
    For $i = 1 To $iBtnNum[0]
        $iBtnNum[$i] = GUICtrlCreateButton($i, $x + 60 * $i, 180, 58, 28)
    Next

    GUISetState()

    Opt("GUIOnEventMode", 0) ; For the loop include the appropriate mode

    While 1
        $msg = GUIGetMsg()
        Switch $msg
            Case $iBtnNum[1] To $iBtnNum[5]
                If $Rnd <> ($msg - $iBtnNum[1] + 1) Then
                    _Crypt_Shutdown()
                    Exit ; If the key number is not equal to Random, then the output
                EndIf
                ExitLoop

            Case $registr
                $login0 = GUICtrlRead($login)
                $pasw0 = GUICtrlRead($pasw)
                If $login0 = '' Or StringLen($login0) < 5 Then
                    MsgBox(0, $aLng[1], $aLng[10])
                    ContinueLoop
                EndIf
                If $pasw0 = '' Or StringLen($pasw0) < 5 Then
                    MsgBox(0, $aLng[1], $aLng[11])
                    ContinueLoop
                EndIf
                ; ClipPut(_GenKey($login0)) ; uncomment to get a temporary key to the clipboard, and perform re-registration.
                $hFile = FileOpen($LK, 16 + 2)
                FileWrite($hFile, _Crypt_EncryptData($login0 & @LF & $pasw0, $sPassKey, $CALG_AES_256)) ; a key encrypts the key file
                FileClose($hFile)
                _restart()
            Case -3
                _Crypt_Shutdown()
                Exit
        EndSwitch
    WEnd
    GUIDelete($hGuiTrial)
    Opt("GUIOnEventMode", 1)
EndFunc   ;==>_Checking_Account

; Here is your key formula. This part of the secret. Everyone comes up with how to do it. I showed primitive option.
Func _GenKey($tmp)
    If $tmp Then
        Local $res = ''
        $tmp = StringTrimLeft(_Crypt_HashData($tmp, $CALG_MD5), 2)
        For $i = 3 To 30 Step 2
            $res &= StringMid($tmp, $i, 1)
        Next
        For $i = 3 To 30 Step 3
            $res &= StringMid($tmp, $i, 1)
        Next
        $tmp = ''
        For $i = 3 To 19 Step 4
            $tmp &= '-' & StringMid($res, $i, 4)
        Next
        $tmp = StringTrimLeft($tmp, 1)
    EndIf
    Return $tmp
EndFunc   ;==>_GenKey

; http://autoit-script.ru/index.php/topic,309.msg2812.html#msg2812
; CreatoR
Func _Restart()
    Local $sAutoIt_File = @TempDir & "\~Au3_ScriptRestart_TempFile.au3"
    Local $sRunLine, $sScript_Content, $hFile

    $sRunLine = @ScriptFullPath
    If Not @Compiled Then $sRunLine = @AutoItExe & ' /AutoIt3ExecuteScript ""' & $sRunLine & '""'
    If $CmdLine[0] > 0 Then $sRunLine &= ' ' & $CmdLineRaw

    $sScript_Content &= '#NoTrayIcon' & @CRLF & _
            'While ProcessExists(' & @AutoItPID & ')' & @CRLF & _
            '   Sleep(10)' & @CRLF & _
            'WEnd' & @CRLF & _
            'Run("' & $sRunLine & '")' & @CRLF & _
            'FileDelete(@ScriptFullPath)' & @CRLF

    $hFile = FileOpen($sAutoIt_File, 2)
    FileWrite($hFile, $sScript_Content)
    FileClose($hFile)

    Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & $sAutoIt_File & '"', @ScriptDir, @SW_HIDE)
    Sleep(1000)
    Exit
EndFunc

.Get key.au3

#include <Crypt.au3>

Local $aLng[5]

$aLng[0] = 'Login'
$aLng[1] = 'Get password'
$aLng[2] = 'Password'
$aLng[3] = 'Error'
$aLng[4] = 'Enter the username of at least 5 characters.'

; Ru
If @OSLang = 0419 Then
    $aLng[0] = 'Логин'
    $aLng[1] = 'Получить пароль'
    $aLng[2] = 'Пароль'
    $aLng[3] = 'Ошибка'
    $aLng[4] = 'Введите логин длинной не менее 5 символов.'
EndIf

_Crypt_Startup()

Local $hGuiTrial, $LK, $login, $login0, $msg, $pasw, $registr
$LK = @ScriptDir & '\LK.key'

GUICreate($aLng[1], 340, 100)

GUICtrlCreateLabel($aLng[0], 10, 12, 45, 20)
$login = GUICtrlCreateInput('', 55, 10, 265, 20)

GUICtrlCreateLabel($aLng[2], 10, 42, 45, 20)
$pasw = GUICtrlCreateInput('', 55, 40, 265, 20)
$registr = GUICtrlCreateButton($aLng[1], 210, 66, 110, 28)

GUISetState()
While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $registr
            $login0 = GUICtrlRead($login)
            If $login0 = '' Or StringLen($login0) < 5 Then
                MsgBox(0, $aLng[3], $aLng[4])
                ContinueLoop
            EndIf
            GUICtrlSetData($pasw, _GenKey($login0))
        Case -3
            _Crypt_Shutdown()
            Exit
    EndSwitch
WEnd

Func _GenKey($tmp)
    If $tmp Then
        Local $res = ''
        $tmp = StringTrimLeft(_Crypt_HashData($tmp, $CALG_MD5), 2)
        For $i = 3 To 30 Step 2
            $res&= StringMid($tmp, $i, 1)
        Next
        For $i = 3 To 30 Step 3
            $res&= StringMid($tmp, $i, 1)
        Next
        $tmp=''
        For $i = 3 To 19 Step 4
            $tmp &= '-' & StringMid($res, $i, 4)
        Next
        $tmp = StringTrimLeft($tmp, 1)
    EndIf
    Return $tmp
EndFunc   ;==>_GenKey
Edited by AZJIO
Link to comment
Share on other sites

Trial Prompt Window, even.

@AZJIO - I thought this was gonna be about something else. In fact, I thought it was gonna be a nag window killer ... not the opposite. So you may want to change your topic title?

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...