Add wfGenerateToken function, to generate a random hex token. Used in CentralAuth...
authorAndrew Garrett <werdna@users.mediawiki.org>
Fri, 11 Apr 2008 00:43:13 +0000 (00:43 +0000)
committerAndrew Garrett <werdna@users.mediawiki.org>
Fri, 11 Apr 2008 00:43:13 +0000 (00:43 +0000)
includes/GlobalFunctions.php

index f28d7cf..51d0749 100644 (file)
@@ -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