OS module in Python provides functions for interacting with the operating system. OS comes under Python’s standard utility modules. This module provides a portable way of using operating system dependent functionality.
os.urandom()
method is used to generate a string of size random bytes suitable for cryptographic use or we can say this method generates a string containing random characters.
Syntax: os.urandom(size)
Parameter:
size: It is the size of string random bytesReturn Value: This method returns a string which represents random bytes suitable for cryptographic use.
Example #1 :
# Python program to explain os.urandom() method # importing os module import os
# Declaring size size = 5
# Using os.urandom() method result = os.urandom(size)
# Print the random bytes string # Output will be different everytime print (result)
|
b'\xe2\xaf\xbc:\xdd'