diff --git a/lib/SimpleSAML/Auth/State.php b/lib/SimpleSAML/Auth/State.php
index 88d8f8589a189f013e04a36bf35a20ec8fc17e6d..f1461c471fcd908eeaa22f5d83251392468445fa 100644
--- a/lib/SimpleSAML/Auth/State.php
+++ b/lib/SimpleSAML/Auth/State.php
@@ -105,7 +105,7 @@ class SimpleSAML_Auth_State {
 		assert('is_bool($rawId)');
 
 		if (!array_key_exists(self::ID, $state)) {
-			$state[self::ID] = SimpleSAML_Utils_Random::generateID();
+			$state[self::ID] = SimpleSAML\Utils\Random::generateID();
 		}
 
 		$id = $state[self::ID];
diff --git a/lib/SimpleSAML/Bindings/Shib13/Artifact.php b/lib/SimpleSAML/Bindings/Shib13/Artifact.php
index 73c7592c770d955b354cabe91ef75c4597a5e4c2..649d7905cac7016771a0fff90e6a549f9efb4cf7 100644
--- a/lib/SimpleSAML/Bindings/Shib13/Artifact.php
+++ b/lib/SimpleSAML/Bindings/Shib13/Artifact.php
@@ -48,7 +48,7 @@ class SimpleSAML_Bindings_Shib13_Artifact {
 		$msg = '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">' .
 			'<SOAP-ENV:Body>' .
 			'<samlp:Request xmlns:samlp="urn:oasis:names:tc:SAML:1.0:protocol"' .
-			' RequestID="' . SimpleSAML_Utils_Random::generateID() . '"' .
+			' RequestID="' . SimpleSAML\Utils\Random::generateID() . '"' .
 			' MajorVersion="1" MinorVersion="1"' .
 			' IssueInstant="' . SimpleSAML\Utils\Time::generateTimestamp() . '"' .
 			'>';
diff --git a/lib/SimpleSAML/Session.php b/lib/SimpleSAML/Session.php
index d4bbaac001e62295aac6097607b518b0f2ebfcbd..42f73b80fe49d0263950264a371a4fc1e04356d4 100644
--- a/lib/SimpleSAML/Session.php
+++ b/lib/SimpleSAML/Session.php
@@ -408,7 +408,7 @@ class SimpleSAML_Session
 
         $this->authData[$authority] = $data;
 
-        $this->authToken = SimpleSAML_Utils_Random::generateID();
+        $this->authToken = SimpleSAML\Utils\Random::generateID();
         $sessionHandler = SimpleSAML_SessionHandler::getSessionHandler();
 
         if (!$this->transient && (!empty($data['RememberMe']) || $this->rememberMeExpire) &&
diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php
index dcd743c9d8564ca428e94f2fc35b67c1c4a140a2..673c5057e47d8b3100297a0cfc2253bceb314a81 100644
--- a/lib/SimpleSAML/Utilities.php
+++ b/lib/SimpleSAML/Utilities.php
@@ -382,10 +382,10 @@ class SimpleSAML_Utilities {
 
 
 	/**
-	 * @deprecated This function will be removed in SSP 2.0. Please use SimpleSAML_Utils_Random::generateID() instead.
+	 * @deprecated This function will be removed in SSP 2.0. Please use SimpleSAML\Utils\Random::generateID() instead.
 	 */
 	public static function generateID() {
-		return SimpleSAML_Utils_Random::generateID();
+		return SimpleSAML\Utils\Random::generateID();
 	}
 
 
@@ -1127,7 +1127,7 @@ class SimpleSAML_Utilities {
 		if ($httpRedirect && preg_match("#^http:#", $destination) && self::isHTTPS()) {
 			$url = self::createHttpPostRedirectLink($destination, $post);
 		} else {
-			$postId = SimpleSAML_Utils_Random::generateID();
+			$postId = SimpleSAML\Utils\Random::generateID();
 			$postData = array(
 				'post' => $post,
 				'url' => $destination,
@@ -1154,7 +1154,7 @@ class SimpleSAML_Utilities {
 		assert('is_string($destination)');
 		assert('is_array($post)');
 
-		$postId = SimpleSAML_Utils_Random::generateID();
+		$postId = SimpleSAML\Utils\Random::generateID();
 		$postData = array(
 			'post' => $post,
 			'url' => $destination,
diff --git a/lib/SimpleSAML/Utils/Random.php b/lib/SimpleSAML/Utils/Random.php
index 11b8a198372508cb44897da6437b0b4994e80847..794c02a7ebe7bd105fe459b09401e7556a4a9bc8 100644
--- a/lib/SimpleSAML/Utils/Random.php
+++ b/lib/SimpleSAML/Utils/Random.php
@@ -1,12 +1,13 @@
 <?php
-
-
 /**
  * Utility class for random data generation and manipulation.
  *
  * @package SimpleSAMLphp
  */
-class SimpleSAML_Utils_Random
+
+namespace SimpleSAML\Utils;
+
+class Random
 {
 
     /**
diff --git a/lib/SimpleSAML/XML/Shib13/AuthnResponse.php b/lib/SimpleSAML/XML/Shib13/AuthnResponse.php
index a70dcb16ac19af2338ad35a21abc74b9451ac3fb..1c5d9fcf6447b96b3068e69ec7df20a49797d33a 100644
--- a/lib/SimpleSAML/XML/Shib13/AuthnResponse.php
+++ b/lib/SimpleSAML/XML/Shib13/AuthnResponse.php
@@ -304,7 +304,7 @@ class SimpleSAML_XML_Shib13_AuthnResponse {
 			$scopedAttributes = array();
 		}
 
-		$id = SimpleSAML_Utils_Random::generateID();
+		$id = SimpleSAML\Utils\Random::generateID();
 		
 		$issueInstant = SimpleSAML\Utils\Time::generateTimestamp();
 		
@@ -313,7 +313,7 @@ class SimpleSAML_XML_Shib13_AuthnResponse {
 		
 		
 		$assertionExpire = SimpleSAML\Utils\Time::generateTimestamp(time() + 60 * 5);# 5 minutes
-		$assertionid = SimpleSAML_Utils_Random::generateID();
+		$assertionid = SimpleSAML\Utils\Random::generateID();
 
 		$spEntityId = $sp->getString('entityid');
 
@@ -321,7 +321,7 @@ class SimpleSAML_XML_Shib13_AuthnResponse {
 		$base64 = $sp->getBoolean('base64attributes', FALSE);
 
 		$namequalifier = $sp->getString('NameQualifier', $spEntityId);
-		$nameid = SimpleSAML_Utils_Random::generateID();
+		$nameid = SimpleSAML\Utils\Random::generateID();
 		$subjectNode =
 			'<Subject>' .
 			'<NameIdentifier' .
diff --git a/modules/adfs/lib/IdP/ADFS.php b/modules/adfs/lib/IdP/ADFS.php
index 341f91e2970f0f69a5c9374cb57d4037f998b0d2..c60e42f1142977e3fc2146030cb9340d3383240a 100644
--- a/modules/adfs/lib/IdP/ADFS.php
+++ b/modules/adfs/lib/IdP/ADFS.php
@@ -50,7 +50,7 @@ class sspmod_adfs_IdP_ADFS {
 		$issueInstant = SimpleSAML\Utils\Time::generateTimestamp();
 		$notBefore = SimpleSAML\Utils\Time::generateTimestamp(time() - 30);
 		$assertionExpire = SimpleSAML\Utils\Time::generateTimestamp(time() + 60 * 5);
-		$assertionID = SimpleSAML_Utils_Random::generateID();
+		$assertionID = SimpleSAML\Utils\Random::generateID();
 		$nameidFormat = 'http://schemas.xmlsoap.org/claims/UPN';
 		$result =
 '<wst:RequestSecurityTokenResponse xmlns:wst="http://schemas.xmlsoap.org/ws/2005/02/trust">
@@ -141,7 +141,7 @@ class sspmod_adfs_IdP_ADFS {
 			}
 			$nameid = $attributes[$nameidattribute][0];
 		} else {
-			$nameid = SimpleSAML_Utils_Random::generateID();
+			$nameid = SimpleSAML\Utils\Random::generateID();
 		}
 
 		$idp = SimpleSAML_IdP::getByState($state);		
diff --git a/modules/casserver/www/login.php b/modules/casserver/www/login.php
index deb1799451460ed2e39832ec69f76f336cac66cd..43e08fb35b15a899f09015dfbba0c89e45ce9e64 100644
--- a/modules/casserver/www/login.php
+++ b/modules/casserver/www/login.php
@@ -41,7 +41,7 @@ $attributes = $as->getAttributes();
 
 $path = $casconfig->resolvePath($casconfig->getValue('ticketcache', '/tmp'));
 
-$ticket = str_replace( '_', 'ST-', SimpleSAML_Utils_Random::generateID() );
+$ticket = str_replace( '_', 'ST-', SimpleSAML\Utils\Random::generateID() );
 storeTicket($ticket, $path, array('service' => $service,
 	'forceAuthn' => $forceAuthn,
 	'attributes' => $attributes,
diff --git a/modules/casserver/www/proxy.php b/modules/casserver/www/proxy.php
index b4f08d55d8031bc0cc0a7856e12d28f114cab138..6fc14e4a31407db3d1adf22f0ec23b6684212336 100644
--- a/modules/casserver/www/proxy.php
+++ b/modules/casserver/www/proxy.php
@@ -26,7 +26,7 @@ $path = $casconfig->resolvePath($casconfig->getValue('ticketcache', 'ticketcache
 
 $ticket = retrieveTicket($pgt, $path, false);
 if ($ticket['validbefore'] > time()) {
-	$pt = str_replace( '_', 'PT-', SimpleSAML_Utils_Random::generateID() );
+	$pt = str_replace( '_', 'PT-', SimpleSAML\Utils\Random::generateID() );
 	storeTicket($pt, $path, array(
 		'service' => $targetService,
 		'forceAuthn' => false,
diff --git a/modules/casserver/www/serviceValidate.php b/modules/casserver/www/serviceValidate.php
index 5a30ec115443679ab8aa8ce7f5a6ea4a3a0615d2..8a413519b76d0e593f9bdb358554f5ef7d6b6de3 100644
--- a/modules/casserver/www/serviceValidate.php
+++ b/modules/casserver/www/serviceValidate.php
@@ -41,8 +41,8 @@ try {
 					
 		if (isset($_GET['pgtUrl'])) {
 			$pgtUrl = $_GET['pgtUrl'];
-			$pgtiou = str_replace( '_', 'PGTIOU-', SimpleSAML_Utils_Random::generateID());
-			$pgt = str_replace( '_', 'PGT-', SimpleSAML_Utils_Random::generateID());
+			$pgtiou = str_replace( '_', 'PGTIOU-', SimpleSAML\Utils\Random::generateID());
+			$pgt = str_replace( '_', 'PGT-', SimpleSAML\Utils\Random::generateID());
 			$content = array(
 				'attributes' => $attributes,
 				'forceAuthn' => false,
diff --git a/modules/consent/templates/consentform.php b/modules/consent/templates/consentform.php
index 004a91e982a99f24fab25503c036830036edfdfe..210fd46aa3ebae87b16ac17e1469a0016236c06a 100644
--- a/modules/consent/templates/consentform.php
+++ b/modules/consent/templates/consentform.php
@@ -167,7 +167,7 @@ function present_attributes($t, $attributes, $nameParent)
 
             $isHidden = in_array($nameraw, $t->data['hiddenAttributes'], true);
             if ($isHidden) {
-                $hiddenId = SimpleSAML_Utils_Random::generateID();
+                $hiddenId = SimpleSAML\Utils\Random::generateID();
 
                 $str .= '<div class="attrvalue" style="display: none;" id="hidden_' . $hiddenId . '">';
             } else {
diff --git a/modules/oauth/lib/OAuthStore.php b/modules/oauth/lib/OAuthStore.php
index 881daf7adc88b399088a8c2234f65cceaa45809c..4e6960a311cdb7b4bc89344cab6d8e6bde81e582 100644
--- a/modules/oauth/lib/OAuthStore.php
+++ b/modules/oauth/lib/OAuthStore.php
@@ -62,7 +62,7 @@ class sspmod_oauth_OAuthStore extends OAuthDataStore {
 		
 		if ($oConsumer && ($oConsumer->callback_url)) $url = $oConsumer->callback_url;
 		
-		$verifier = SimpleSAML_Utils_Random::generateID();
+		$verifier = SimpleSAML\Utils\Random::generateID();
 		$url = SimpleSAML_Utilities::addURLparameter($url, array("oauth_verifier"=>$verifier));
 		
 		$this->store->set('authorized', $requestTokenKey, $verifier, $data, $this->config->getValue('requestTokenDuration', 60*30) );
@@ -138,7 +138,7 @@ class sspmod_oauth_OAuthStore extends OAuthDataStore {
 		
 		$lifetime = $this->config->getValue('requestTokenDuration', 60*30); 
 		
-		$token = new OAuthToken(SimpleSAML_Utils_Random::generateID(), SimpleSAML_Utils_Random::generateID());
+		$token = new OAuthToken(SimpleSAML\Utils\Random::generateID(), SimpleSAML\Utils\Random::generateID());
 		$token->callback = $callback;	// OAuth1.0-RevA
 		$this->store->set('request', $token->key, $consumer->key, $token, $lifetime);
 		
@@ -158,7 +158,7 @@ class sspmod_oauth_OAuthStore extends OAuthDataStore {
 
     function new_access_token($requestToken, $consumer, $verifier = null) {
 		SimpleSAML_Logger::info('OAuth new_access_token(' . $requestToken . ',' . $consumer . ')');
-		$accestoken = new OAuthToken(SimpleSAML_Utils_Random::generateID(), SimpleSAML_Utils_Random::generateID());
+		$accestoken = new OAuthToken(SimpleSAML\Utils\Random::generateID(), SimpleSAML\Utils\Random::generateID());
 		// SimpleSAML_Logger::info('OAuth new_access_token(' . $requestToken . ',' . $consumer . ',' . $accestoken . ')');
 		$this->store->set('access', $accestoken->key, $consumer->key, $accestoken, $this->config->getValue('accessTokenDuration', 60*60*24) );
         return $accestoken;
diff --git a/modules/oauth/www/registry.edit.php b/modules/oauth/www/registry.edit.php
index ee69a1e59c225965e5bd5c017c0248fc7b36194a..ca5ba80659132dd32969bfb4174c6ce2e78532ce 100644
--- a/modules/oauth/www/registry.edit.php
+++ b/modules/oauth/www/registry.edit.php
@@ -37,8 +37,8 @@ if (array_key_exists('editkey', $_REQUEST)) {
 } else {
 	$entry = array(
 		'owner' => $userid,
-		'key' => SimpleSAML_Utils_Random::generateID(),
-		'secret' => SimpleSAML_Utils_Random::generateID(),
+		'key' => SimpleSAML\Utils\Random::generateID(),
+		'secret' => SimpleSAML\Utils\Random::generateID(),
 	);
 }
 
diff --git a/modules/saml/lib/Auth/Process/TransientNameID.php b/modules/saml/lib/Auth/Process/TransientNameID.php
index 7451e45e2093f15143e41ff069d08bab8bea20ec..b432ed35a24e2cec2955e669ea7e3d21db1b9ac4 100644
--- a/modules/saml/lib/Auth/Process/TransientNameID.php
+++ b/modules/saml/lib/Auth/Process/TransientNameID.php
@@ -28,7 +28,7 @@ class sspmod_saml_Auth_Process_TransientNameID extends sspmod_saml_BaseNameIDGen
 	 */
 	protected function getValue(array &$state) {
 
-		return SimpleSAML_Utils_Random::generateID();
+		return SimpleSAML\Utils\Random::generateID();
 	}
 
 }
diff --git a/modules/saml/lib/IdP/SAML2.php b/modules/saml/lib/IdP/SAML2.php
index 82b7e90aa2c79a63fd375c4b0c6a76528813aa5c..c67ecf5a3f0fae439a130789e2228e2bf1d6f3ec 100644
--- a/modules/saml/lib/IdP/SAML2.php
+++ b/modules/saml/lib/IdP/SAML2.php
@@ -809,7 +809,7 @@ class sspmod_saml_IdP_SAML2 {
 		$sessionLifetime = $config->getInteger('session.duration', 8*60*60);
 		$a->setSessionNotOnOrAfter(time() + $sessionLifetime);
 
-		$a->setSessionIndex(SimpleSAML_Utils_Random::generateID());
+		$a->setSessionIndex(SimpleSAML\Utils\Random::generateID());
 
 		$sc = new SAML2_XML_saml_SubjectConfirmation();
 		$sc->SubjectConfirmationData = new SAML2_XML_saml_SubjectConfirmationData();
@@ -892,7 +892,7 @@ class sspmod_saml_IdP_SAML2 {
 
 			if ($nameIdFormat === SAML2_Const::NAMEID_TRANSIENT) {
 				/* generate a random id */
-				$nameIdValue = SimpleSAML_Utils_Random::generateID();
+				$nameIdValue = SimpleSAML\Utils\Random::generateID();
 			} else {
 				/* this code will end up generating either a fixed assigned id (via nameid.attribute)
 				   or random id if not assigned/configured */
@@ -900,7 +900,7 @@ class sspmod_saml_IdP_SAML2 {
 				if ($nameIdValue === NULL) {
 					SimpleSAML_Logger::warning('Falling back to transient NameID.');
 					$nameIdFormat = SAML2_Const::NAMEID_TRANSIENT;
-					$nameIdValue = SimpleSAML_Utils_Random::generateID();
+					$nameIdValue = SimpleSAML\Utils\Random::generateID();
 				}
 			}
 
diff --git a/modules/saml/lib/SP/LogoutStore.php b/modules/saml/lib/SP/LogoutStore.php
index 7a3d36a867a853ac3f1fce22605116de10467092..fa78cdfac16aac7e8c401bbd475c3fadc45398e1 100644
--- a/modules/saml/lib/SP/LogoutStore.php
+++ b/modules/saml/lib/SP/LogoutStore.php
@@ -167,7 +167,7 @@ class sspmod_saml_SP_LogoutStore {
 			 * it supports SLO, but we don't want an LogoutRequest with a specific
 			 * SessionIndex to match this session. We therefore generate our own session index.
 			 */
-			$sessionIndex = SimpleSAML_Utils_Random::generateID();
+			$sessionIndex = SimpleSAML\Utils\Random::generateID();
 		}
 
 		$store = SimpleSAML_Store::getInstance();
diff --git a/www/authmemcookie.php b/www/authmemcookie.php
index ca9450f363e609fe340467e78bf01ced5cbb56b1..00cf2e65661c0dcf30395a5c058925d19b4b632e 100644
--- a/www/authmemcookie.php
+++ b/www/authmemcookie.php
@@ -31,7 +31,7 @@ try {
 	$s->requireAuth();
 
 	/* Generate session id and save it in a cookie. */
-	$sessionID = SimpleSAML_Utils_Random::generateID();
+	$sessionID = SimpleSAML\Utils\Random::generateID();
 
 	$cookieName = $amc->getCookieName();