How to Generate Custom Length Passwords for Apple Passwords App

In my previous post, though I didn’t go into any details as to what limitations I’ve faced, I believe I’ve hinted enough that Apple’s Passwords app has missed the mark on the convenience features. One of which was rather shocking; the app doesn’t let a user generate a custom length password. The app is certainly capable of generating two kinds of passwords, one with special characters and one without, but not all websites are open to take them, let alone it will accept such a long password.

Indeed, Apple is manhandling its user base into stronger passwords. There is no argument to be made against having longer random passwords. However, the ones who are in control of these services are most likely not the users. And anyone who has dealt with IT or customer support of any kind would agree that it is universally acknowledged truth, that one in control of IT policies, must be in want of ignorant ‘non-technical mortals’.

If you are familiar with how I would handle problems such as this, here is a short Python script to bail us all out. It will ask for the desired length in each prompt, and should the desired length be too short, it will ask the user again. As before, the generated password will contain at least one of each lowercase, uppercase, digits, and special characters. You can change special_character_permitted value that will fit the password policy as well.

# !/usr/bin/env python3
	
import secrets
import string

special_character_permitted = ['!','@','#','$', '^', '&']

set_length = int(input("Enter desired password length: "))
while set_length < 4:
	set_length = input("Too short. Try again: ")		

special_character_permitted = ''.join(str(i) for i in special_character_permitted)
string_mix = [string.ascii_lowercase, 
	string.ascii_uppercase, 
	string.digits, 
	special_character_permitted]

pattern = [None for i in range(set_length)]

for idx in string_mix:
	while True:
		fidx = secrets.randbelow(set_length)
		if pattern[fidx] is None:
			pattern[fidx] = secrets.choice(idx)
			break

string_mix = string.ascii_letters + string.digits + special_character_permitted
for idx in range(set_length):
	if pattern[idx] is None:
		pattern[idx] = secrets.choice(string_mix)

print(*pattern, sep='')

If you are using Apple Passwords app, I’m afraid this short script is paramount to make the password manager universal across all apps and services. Most of the banking apps I have still require 12-16 characters long password, and that’s the maximum, not the minimum. Ultimately, the most secure solution would be to have longer passwords in general; which would necessitate the use of password managers, but free and reliable managers are available, and Apple’s is one of them.

Leave a comment