Jump to content
Sign in to follow this  

DM Create Serial keys for your software.

Recommended Posts

hi this is my little 2 cents of how to create a list of random list of serials you can use for your software.

Hope you may find it us full. Comments are welcome.

The code

Local Enum $MaskAlpha = 0, $MaskDigits, $MaskAlphaNum

Func RandomPassword($Length, $Mask = $MaskAlpha)
    Local $buff
    Local $i
    Local $n
    Local $PwsBuff
    Const $Digits = "0123456789"

    Switch $Mask
        Case $MaskAlpha
            $PwsBuff = $AlphaU
        Case $MaskDigits
            $PwsBuff = $Digits
        Case $MaskAlphaNum
            $PwsBuff = $AlphaU & $Digits

    ;This creates the random password.
    For $i = 1 To $Length
        ;Pick a random chat between 1 and the pwsMask Length
        $n = Int(Random(1, StringLen($PwsBuff)))
        ;Concat each chat that has been picked out of pwsMask to $buff
        $buff &= StringMid($PwsBuff, $n, 1)
    Return $buff
EndFunc   ;==>RandomPassword

Func CreateSerial($Cols, $CharsPerCol, $Rows, $Mask = $MaskAlpha, $ColSep = "-")
    Local $i, $n
    Local $Buffer

    For $n = 0 To $Rows - 1
        For $i = 0 To $Cols - 1
            $PwsSet = RandomPassword($CharsPerCol, $Mask)
            ;Build serial
            $Buffer &= $PwsSet & $ColSep
        ;Remove last $ColSep
        $Buffer = StringTrimRight($Buffer, 1) & @CRLF

    $PwsBuff = ""
    Return $Buffer
    $Buffer = ""
EndFunc   ;==>CreateSerial

Func Main()

    Local $Cols
    Local $CharPerCol
    Local $Rows
    Local $Mask
    Local $List

    $cmd = $CmdLine

    If UBound($cmd) < 4 Then
        ConsoleWrite("Incorrect syntext")
        $Cols = $cmd[1]
        $CharPerCol = $cmd[2]
        $Rows = $cmd[3]

    If UBound($cmd) > 4 Then
        $Mask = $cmd[4]
    ;Create the random serials
    $List = CreateSerial($Cols, $CharPerCol, $Rows, $Mask, "-")
    ;Output list
    ;Clear up
    $cmd = Null
    $List = Null
EndFunc   ;==>Main

;Call main func

Example batch to create the serials with the above code.


REM cols the number of colums to create.
REM parts is the number of echo serial has.
REM is the number of rows to create.
REM 0 at the end if the format eg 0=Alpha,1=Digits,2=Alpha+Digits

set cols=5
set parts=5
set rows=10

SerialGen.exe %cols% %parts% %rows% 0 > serials.txt
Edited by DreamVB

On Error Resume Pulling Hair Out.

Share this post

Link to post
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
Sign in to follow this  

  • Create New...