Hi All
I recently started to code some scripts on MK, and i really wanted to have a script that could generate a random string and that string i would then use to weekly change my wi-fi password. After bit investigation, i did not find anything that could immediately sort my issue so i decided to code my own script and i believe it might be useful for the others if it doesnt exist yet.
The below script was tested and work on 6.32 and 6.32.3 versions. Give it a try and please give suggestions.
Copy and paste from here:
This Script Was Created BY TSOKOTSA 2015 and it was made to Generate a Random String With 8 Digits for The GUEST WI-FI Internet
Here i get the hour, minutes and seconds
:local time [:pick [/system clock get time] 0 2];
:local min [:pick [/system clock get time] 3 5];
:local sec [:pick [/system clock get time] 6 8];
for each value that i pick, i also get the inverse combination of the value. lets say that the seconds are 29 by the time # the script executes, i also get the 92 which is the inverse of the 29. i do that for all values time, minutes and sec.
:local char;
:set char ( $char . [ :pick $time 1 ] . [ :pick $time 0 ]);
:local char1;
:set char1 ( $char1 . [ :pick $min 1 ] . [ :pick $min 0 ]);
:local char2;
:set char2 ( $char2 . [ :pick $sec 1 ] . [ :pick $sec 0 ]);
Here i have an array. This array must be long enough to accommodate the sum of the highest possible values of the # combination.
e.g the highest possible of normal time / hour / sec is 23:59:59. so the inverse of that would be 32:95:95
so the sum of that inverse should not be longer than the array. so have that in mind.
On my array i did generate a random string online you can use mine or generate your own with your possible values.
:local arrayalpha ("2","C","h","Y","!","f","j","c","}","q","k",":","(","}","3","Y","T","|","C","v","}","n","8","I","r","4","p","V","6",":","S","V","=","p","Z","T","6",")","l",":","K","b","=","Y","7","X","c","P","@","g","m","U","T","","g","v","N","j","E","g","f","D","h","!","W","p","U","z","T","S","}","h","M","Y","i","E","c","4","!","Q","(","<","Y","h","@","e","q","7","]","l","R","-","h","S","w","(",">","/","r","=","<","I","&","5","@","!","|","h","p","l","1","Y","U","2","J","R","T","Y","}","=","b","c","$","9","d","e","@","S","6","W","B","Q","$","S","b","p","}","3","m","X","g","8","y","j","h","S","Z","F","@","!","t","}","!","U","j","/","W","5","}","a","g","!","S","S","T","{","7","f","G","W","T","","/","k","3","+","T","X","p","m","!","e","i","L","]","3","d","G","T","+","@","H","!","Q","k","X","@","P","Q","+","k","f","K","T","S","{","Q","W","S","<","S","z","z","k","V","@","X","{","4","g","t","X","1","h","5","k","T","","f","i","{","]","(","Y","/","1","j","h","l","]","S","3","b","Y",":","i","T","j","h","T","7","w","g","D","X","g","T","T","i","|","S","R","!","}","D","d","c","h","d","T","l","N",")","V","u","Z","T","}",":","{","S","m","Z","d","}","Z","Z","S","Y","|","","d","k","v","h","(","7","/","-");
How do i ensure a complex string? Because it is impossible to determinate the seconds at the time the script is
executed and in addition to that it is almos impossible to determinate the inverse number of the seconds and most # impossible to determinate the sum of the inverses.
:local new;
:set new ( $new . [ :pick $arrayalpha ($time+$min+$sec) ] . [ :pick $arrayalpha ($time+$sec) ] . [ :pick $arrayalpha ($min+$sec) ] . [ :pick $arrayalpha $sec ] . [ :pick $arrayalpha $char ] . [ :pick $arrayalpha $char1 ] . [ :pick $arrayalpha $char2 ] . [ :pick $arrayalpha ($char+$char1+$char2) ]);
\
This line doesnt actulay make any difference to the code, it only determinate the array lengh and can be commented. it is only used for debugging purposes.
:local arrlengh [:len $arrayalpha];
:log warning "Our Array Lengh is $arrlengh Your New String is $new";
If you face any error executing the script, might be because of the comments so check comments to clear error.

