From 4f61581a9091237b8600d22e471480e51853c3e4 Mon Sep 17 00:00:00 2001 From: Andrew Garrett Date: Fri, 11 Apr 2008 00:43:13 +0000 Subject: [PATCH] Add wfGenerateToken function, to generate a random hex token. Used in CentralAuth, currently. --- includes/GlobalFunctions.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index f28d7cf9ea..51d0749f0a 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2502,3 +2502,12 @@ function wfWaitForSlaves( $maxLag ) { } } } + +/** Generate a random 32-character hexadecimal token. + * @param mixed $salt Some sort of salt, if necessary, to add to random characters before hashing. + */ + function wfGenerateToken( $salt = '' ) { + $salt = serialize($salt); + + return md5( mt_rand( 0, 0x7fffffff ) . $salt ); + } \ No newline at end of file -- 2.20.1