Commit f49b67f5 authored by Christian Hesse's avatar Christian Hesse

global-functions: add $GetRandom

parent 25a22e2e
......@@ -245,3 +245,16 @@
}
:return $Result;
}
# generate random number
# Warning: This is a *very* weak algorithm and in *no way*
# useful for cryptography or similar!
:global GetRandom do={
:local Max ([ :tonum $1 ] + 1);
:local Sum 0;
:foreach Interface in=[ /interface find ] do={
:set Sum ($Sum + [ /interface get $Interface tx-byte ]);
}
:return ($Sum % $Max);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment