DreamVB Posted October 12, 2014 Share Posted October 12, 2014 (edited) 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 expandcollapse popup#Region #AutoIt3Wrapper_Change2CUI=y #EndRegion Local Enum $MaskAlpha = 0, $MaskDigits, $MaskAlphaNum Func RandomPassword($Length, $Mask = $MaskAlpha) Local $buff Local $i Local $n Local $PwsBuff Const $AlphaU = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" Const $Digits = "0123456789" Switch $Mask Case $MaskAlpha $PwsBuff = $AlphaU Case $MaskDigits $PwsBuff = $Digits Case $MaskAlphaNum $PwsBuff = $AlphaU & $Digits EndSwitch ;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) Next 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 Next ;Remove last $ColSep $Buffer = StringTrimRight($Buffer, 1) & @CRLF Next $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") Exit Else $Cols = $cmd[1] $CharPerCol = $cmd[2] $Rows = $cmd[3] EndIf If UBound($cmd) > 4 Then $Mask = $cmd[4] EndIf ;Create the random serials $List = CreateSerial($Cols, $CharPerCol, $Rows, $Mask, "-") ;Output list ConsoleWrite($List) ;Clear up $cmd = Null $List = Null EndFunc ;==>Main ;Call main func Main() Example batch to create the serials with the above code. @ECHO OFF 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 exit Edited October 12, 2014 by DreamVB On Error Resume Pulling Hair Out. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now