You can download this code by clicking the button below.
This code is now available for download.
This function generates a random password of a specified length, consisting of letters, numbers, and special characters.
Technology Stack : os, re, json, random, string, shutil, datetime, time
Code Type : Password generator
Code Difficulty : Beginner
import os
import re
import json
import random
import string
import shutil
import datetime
import time
def generate_random_password(length=8):
if length < 8:
raise ValueError("Password length must be at least 8 characters")
characters = string.ascii_letters + string.digits + "!@#$%^&*()_+-="
return ''.join(random.choice(characters) for i in range(length))