bundleid DELL connections 1260B94B-9181-4C34-8D40-6810254B059E destinationuid 6A745F91-F8E2-4F85-81D9-E031FDE3494C modifiers 0 modifiersubtext vitoclose 6599D4CA-1A0C-4D9F-AA4A-B96242444DE3 destinationuid 1260B94B-9181-4C34-8D40-6810254B059E modifiers 0 modifiersubtext vitoclose 6A745F91-F8E2-4F85-81D9-E031FDE3494C destinationuid 3F4C2ACB-DDCD-4DEE-B331-0B7B018EC3D3 modifiers 0 modifiersubtext vitoclose createdby Timmy description disabled name 無腦生密碼 objects config autopaste clipboardtext {query} ignoredynamicplaceholders transient type alfred.workflow.output.clipboard uid 6A745F91-F8E2-4F85-81D9-E031FDE3494C version 3 config lastpathcomponent onlyshowifquerypopulated removeextension text 搞定!密碼已經複製到剪貼簿囉。 title 無腦生密碼 type alfred.workflow.output.notification uid 3F4C2ACB-DDCD-4DEE-B331-0B7B018EC3D3 version 1 config argumenttrimmode 0 argumenttype 2 fixedorder items [{"title":"Easy to Read","arg":"easy_to_read"},{"title":"All Characters","arg":"all_characters"}] keyword pwgen matchmode 0 runningsubtext subtext title withspace type alfred.workflow.input.listfilter uid 6599D4CA-1A0C-4D9F-AA4A-B96242444DE3 version 1 config concurrently escaping 68 script #!/usr/bin/env -S uv run # /// script # requires-python = ">=3.12" # /// import secrets import string import sys from abc import ABC, abstractmethod # 定義基礎介面 (Optional, 但既然你喜歡結構就做完整點) class PasswordGenerator(ABC): def __init__(self, length: int = 16): self.length = length @property @abstractmethod def characters(self) -> str: pass def generate(self) -> str: # 這裡改用 secrets (Cryptographically secure) return "".join(secrets.choice(self.characters) for _ in range(self.length)) # 實作各種類型 class EasyToSay(PasswordGenerator): """只使用大小寫字母,不含數字符號""" @property def characters(self): return string.ascii_letters class EasyToRead(PasswordGenerator): """排除容易混淆的字元 (0, O, 1, l)""" @property def characters(self): # 建立排除表 exclude = str.maketrans('', '', '0O1l') chars = string.ascii_letters + string.digits return chars.translate(exclude) class AllCharacters(PasswordGenerator): """包含所有符號,最強密碼""" @property def characters(self): return string.ascii_letters + string.digits + string.punctuation # 工廠模式選擇器 def get_password(style: str, length: int = 16) -> str: generators = { "easy_to_say": EasyToSay, "easy_to_read": EasyToRead, "all_characters": AllCharacters, } # 預設使用 AllCharacters 以防萬一 generator_class = generators.get(style, AllCharacters) return generator_class(length).generate() if __name__ == "__main__": # 接收 Alfred 傳來的參數 if len(sys.argv) > 1: query = sys.argv[1] else: query = "all_characters" # 產生並輸出 (沒有換行符號,方便直接貼上) sys.stdout.write(get_password(query)) scriptargtype 1 scriptfile type 9 type alfred.workflow.action.script uid 1260B94B-9181-4C34-8D40-6810254B059E version 2 readme uidata 1260B94B-9181-4C34-8D40-6810254B059E xpos 255 ypos 155 3F4C2ACB-DDCD-4DEE-B331-0B7B018EC3D3 xpos 620 ypos 155 6599D4CA-1A0C-4D9F-AA4A-B96242444DE3 xpos 80 ypos 155 6A745F91-F8E2-4F85-81D9-E031FDE3494C xpos 430 ypos 155 userconfigurationconfig webaddress