aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--global-functions13
1 files changed, 13 insertions, 0 deletions
diff --git a/global-functions b/global-functions
index fb30680..6f1776b 100644
--- a/global-functions
+++ b/global-functions
@@ -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);
+}