diff --git a/lib/utils.py b/lib/utils.py
index d5ca93d55bea7cc88754524baed998557604a6cb..1489ed5797efa8f1b421072fa18c77ddd9a808f7 100644
--- a/lib/utils.py
+++ b/lib/utils.py
@@ -1157,17 +1157,19 @@ def NewUUID():
     f.close()
 
 
-def GenerateSecret():
+def GenerateSecret(numbytes=20):
   """Generates a random secret.
 
-  This will generate a pseudo-random secret, and return its sha digest
+  This will generate a pseudo-random secret returning an hex string
   (so that it can be used where an ASCII string is needed).
 
+  @param numbytes: the number of bytes which will be represented by the returned
+      string (defaulting to 20, the length of a SHA1 hash)
   @rtype: str
-  @return: a sha1 hexdigest of a block of 64 random bytes
+  @return: an hex representation of the pseudo-random sequence
 
   """
-  return sha1(os.urandom(64)).hexdigest()
+  return os.urandom(numbytes).encode('hex')
 
 
 def EnsureDirs(dirs):