-
Notifications
You must be signed in to change notification settings - Fork 1
/
pwgen.py
43 lines (33 loc) · 791 Bytes
/
pwgen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# -*- coding: utf-8 -*-
"""Generate passwords of a specified length."""
from albert import *
import string
import secrets
__title__ = "Password generator"
__version__ = "0.4.1"
__triggers__ = "pw"
__authors__ = "Benjamin Altpeter"
iconPath = iconLookup("password")
def handleQuery(query):
if not query.isTriggered:
return
length = 25
try:
length = int(query.string.strip())
except:
pass
results = []
pw = ''.join(secrets.choice(string.ascii_letters + string.digits) for i in range(length))
results.append(
Item(
id=__title__,
icon=iconPath,
text=pw,
subtext="Your generated password of length " + str(length),
completion=pw,
actions=[
ClipAction("Copy URL", pw)
]
)
)
return results