From ea2edc7297e244458b6bfc74f5ed83e6e4c2e074 Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Sun, 8 Aug 2010 17:42:04 +0200 Subject: [PATCH] [molecule.utils] add get_random_str() --- molecule/utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/molecule/utils.py b/molecule/utils.py index d84f402..df1147f 100644 --- a/molecule/utils.py +++ b/molecule/utils.py @@ -142,6 +142,16 @@ def get_random_number(): """ return random.randint(0, 99999) +def get_random_str(str_len): + """ + Return a random string of length str_len. It uses os.urandom() + @param str_len: byte length + @type str_len: int + @return: random string + @rtype: str + """ + return os.urandom(str_len) + def md5sum(filepath): """ Calcuate md5 hash of given file path.