Community discussions

MikroTik App
 
alisc
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 60
Joined: Thu Dec 01, 2011 10:51 am

Random Number Generation

Thu Feb 02, 2017 6:26 pm

Hi friends
I hope you are fine


How can I create a completely random 8-character words?
Characters, including uppercase and lowercase letters, numbers, special characters

I've made an array but I think it is wrong
And I do not know how these random
So that does not follow a specific algorithm!
100% random
# define char table
:global Number 0123456789
:global CharCap ABCDEFGHIJKLMNOPQRSTUVWXYZ
:global CharLow abcdefghijklmnopqrstuvwxyz
:global CharSpe !@#$%^&*()_+|\=-/.,<>?;':"[]{}
Do you know a better way?


Thanks for your attention
Kind Regards
Good luck to you
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7195
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Random Number Generation

Thu Feb 02, 2017 6:36 pm

 
alisc
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 60
Joined: Thu Dec 01, 2011 10:51 am

Re: Random Number Generation

Fri Feb 03, 2017 9:48 am

thanks dear mrz
But its very very difficult for me !!
Is it easier to identify possible?
 
alisc
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 60
Joined: Thu Dec 01, 2011 10:51 am

Re: Random Number Generation

Fri Feb 03, 2017 10:20 am

i found god script and edit this , but this script have a delay to generate random Password :

how to remove this delay ?

When I click on Run Script, takes at least 1 minute to provide a password !!! ( delay : 1 to 2 min / to generate password )

# MikroTik Random Password Generator
# with random start offset delay for use with /System Scheduler
# Author: Bob Burley - April 25, 2011
#

:local random 0
:local charStrNum 1
:local p1
:local var1
:local var2
:local var3
:local newPassword ""

# set password length here
:local newPassLength 8

# Total characters to choose from is 73
# Eliminated confusing characters
# '0' (zero) and Upper Case 'O'
# '1' (one) and Upper Case 'I' and Lower Case 'l' (L)
:local charStr1 "23456789ABCDEFGHJKLMNPQRSTUVWXYZ23456789abcdefghijkmnopqrstuvwxyz23456789"
:local charStr2 "cN47iKd2bLn8sQz4JAu2PD6Vm5RjTG4UrFY78XewHE3W9gMq62v7a9Z5yf5pC3k6xt9Bh8S3o"
:local charStr3 "uYswW92z6M5fJynQp6hGm5VSr4oR8k7A2bKq5U3FiZvc8gHP2tdL9E4jBT3X7xC6N4D8e7a93"




:for char from=1 to=$newPassLength step=1 do={
#  Generate number between 0 and 72
  :set var1 ([:pick [/system clock get time] 6 8])
  :set p1 ([:len [/system resource get uptime]])
  :set var2 ([:pick [/system resource get uptime] ($p1-2) $p1])
  :set var3 (($var1 * $var2) / 48)

#  pick next character to add to the new password
  :if ($charStrNum=1) do={
    :set newPassword ($newPassword . [:pick $charStr1 $var3])
  }
  :if ($charStrNum=2) do={
    :set newPassword ($newPassword . [:pick $charStr2 $var3])
  }
  :if ($charStrNum=3) do={
    :set newPassword ($newPassword . [:pick $charStr3 $var3])
  }
  :set charStrNum ($charStrNum + 1)
  :if ($charStrNum = 4) do={
    :set charStrNum 1
  }
  :delay (($var1 + $var2 + $var3) / 5)
}

:log info $newPassword
 
td32
Member Candidate
Member Candidate
Posts: 112
Joined: Fri Nov 18, 2016 5:55 am

Re: Random Number Generation

Fri Feb 03, 2017 3:38 pm

Perhaps you can play with this command
:delay (($var1 + $var2 + $var3) / 5)
 
alisc
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 60
Joined: Thu Dec 01, 2011 10:51 am

Re: Random Number Generation

Fri Feb 03, 2017 4:47 pm

Yes that's right
Solve the problem by changing the line

thank you