import secrets
import base64


def generate_password(length):
  """
  Generates a secure random password, similar to `openssl rand -base64 [length]`.
  """
  password_bytes = secrets.token_bytes(length)
  password_b64 = base64.b64encode(password_bytes)
  return password_b64.decode()