Guide (Alternative way to generate random string)



  • Hello guys

    Here a script and guide, to generate random string for those OB user having issue with "FUNCTION Block" random string, since after a while randomly become zeros "0000"

    Update: for better understanding the output variable is "rnd" wherever you need the random just use <rnd>.
    parse block don't need it unless you want to Prefix, Suffix or do crazy stuff

    Just copy this 👇 and replace your FUNCTION Block on LoliScript view

    #RANDOM-SEED FUNCTION Constant "0123456789" -> VAR "ChrSET" 
    #RANDOM-LENGTH FUNCTION Constant "6" -> VAR "RndL" 
    BEGIN SCRIPT JavaScript
    var charU = ChrSET;
    var lengthU = RndL;
    var rnd = '';
    for (var i=0; i<lengthU; i++){
     var rnumU = Math.floor(Math.random() * charU.length);
     rnd += charU.substring(rnumU,rnumU+1);
     }
    var str = "rnd";
    END SCRIPT -> VARS "rnd"
    PARSE "<rnd>" LR "" "" -> VAR "Random"
    

    On Random-Seed Block (Input string Box) typewriter any characters you want to randomize👇
    Seed.PNG

    On Random-Length Block (Input string Box) typewriter any number according with the random length you want👇
    RnL.PNG

    another example using letters 👇
    RndL.PNG



  • Why the last line?
    Just use <rnd> wherever you need it and done.



  • The intention was to let people know that the output variable is "rnd", my bad I didn't explain it well



  • Thanks dude !



  • Thanks dude !!!!


Log in to reply