You can download this code by clicking the button below.
This code is now available for download.
Generates a random password of a specified length composed of letters and digits.
Technology Stack : os, re, sys, json, time, random, string, math, calendar, hashlib, urllib.request
Code Type : Password generation
Code Difficulty : Intermediate
import os
import re
import sys
import json
import time
import random
import string
import math
import calendar
import hashlib
import urllib.request
def generate_random_password(length=12):
if length < 8:
raise ValueError("Password length should be at least 8 characters")
characters = string.ascii_letters + string.digits
password = ''.join(random.choice(characters) for i in range(length))
return password