New in version 2014.7.0.
New in version 2014.7.0.
Changed in version 3004: Changed the default character set used to include symbols and implemented arguments to control the used character set.
Returns a random string of the specified length.
Any valid number of bytes.
New in version 3004.
String with any character that should be used to generate random string.
This argument supersedes all other character controlling arguments.
New in version 3004.
Use lowercase letters in generated random string.
(see string.ascii_lowercase
)
This argument is superseded by chars.
New in version 3004.
Use uppercase letters in generated random string.
(see string.ascii_uppercase
)
This argument is superseded by chars.
New in version 3004.
Use digits in generated random string.
(see string.digits
)
This argument is superseded by chars.
New in version 3004.
Use printable characters in generated random string and includes lowercase, uppercase,
digits, punctuation and whitespace.
(see string.printable
)
It is disabled by default as includes whitespace characters which some systems do not handle well in passwords. This argument also supersedes all other classes because it includes them.
This argument is superseded by chars.
New in version 3004.
Use punctuation characters in generated random string.
(see string.punctuation
)
This argument is superseded by chars.
New in version 3004.
Use whitespace characters in generated random string.
(see string.whitespace
)
It is disabled by default as some systems do not handle whitespace characters in passwords well.
This argument is superseded by chars.
CLI Example:
salt '*' random.get_str 128
salt '*' random.get_str 128 chars='abc123.!()'
salt '*' random.get_str 128 lowercase=False whitespace=True
New in version 2014.7.0.
Encodes a value with the specified encoder.
The value to be hashed.
The algorithm to use. May be any valid algorithm supported by hashlib.
CLI Example:
salt '*' random.hash 'I am a string' md5
Returns a random integer number between the start and end number.
New in version 2015.5.3.
Any valid integer number
Any valid integer number
Optional hashable object
Changed in version 2019.2.0: Added seed argument. Will return the same result when run with the same seed.
CLI Example:
salt '*' random.rand_int 1 10
Return a given sample size from a list. By default, the random number generator uses the current system time unless given a seed value.
New in version 3005.
A list to e used as input.
The sample size to return.
Any value which will be hashed as a seed for random.
CLI Example:
salt '*' random.sample '["one", "two"]' 1 seed="something"
Returns a random number within a range. Optional hash argument can be any hashable object. If hash is omitted or None, the id of the minion is used.
New in version 2015.8.0.
Any hashable object.
Any valid integer number
CLI Example:
salt '*' random.seed 10 hash=None
Generates a salted hash suitable for /etc/shadow.
Salt to be used in the generation of the hash. If one is not provided, a random salt will be generated.
Value to be salted and hashed. If one is not provided, a random password will be generated.
Hash algorithm to use.
CLI Example:
salt '*' random.shadow_hash 'My5alT' 'MyP@asswd' md5
Return a shuffled copy of an input list. By default, the random number generator uses the current system time unless given a seed value.
New in version 3005.
A list to be used as input.
Any value which will be hashed as a seed for random.
CLI Example:
salt '*' random.shuffle '["one", "two"]' seed="something"
New in version 2014.7.0.
The value to be encoded.
The encoder to use on the subsequent string.
CLI Example:
salt '*' random.str_encode 'I am a new string' base64