-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
53 lines (39 loc) · 2.15 KB
/
main.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
44
45
46
47
48
49
50
51
52
53
import logging
import os
from ulauncher.api.client.Extension import Extension
from ulauncher.api.client.EventListener import EventListener
from ulauncher.api.shared.event import KeywordQueryEvent, ItemEnterEvent
from ulauncher.api.shared.item.ExtensionResultItem import ExtensionResultItem
from ulauncher.api.shared.action.RenderResultListAction import RenderResultListAction
from ulauncher.api.shared.action.CopyToClipboardAction import CopyToClipboardAction
from ulauncher.api.shared.action.ExtensionCustomAction import ExtensionCustomAction
from ulauncher.api.shared.action.HideWindowAction import HideWindowAction
logger = logging.getLogger(__name__)
class EnpassExtension(Extension):
def __init__(self):
logger.info('init Enpass extension')
super(EnpassExtension, self).__init__()
self.subscribe(KeywordQueryEvent, KeywordQueryEventListener())
class KeywordQueryEventListener(EventListener):
def on_event(self, event, extension):
items = []
rawstr = event.get_argument()
if rawstr is None:
rawstr = ""
php_password_default = os.popen("php -r 'echo password_hash(\"%s\", PASSWORD_DEFAULT);'" % rawstr).read()
php_bycrypt = os.popen("php -r 'echo password_hash(\"%s\", PASSWORD_BCRYPT);'" % rawstr).read()
items.append(ExtensionResultItem(icon='images/icon.png',
name=php_password_default,
description='PHP PASSWORD_DEFAULT',
highlightable=False,
on_enter=CopyToClipboardAction(php_password_default)
))
items.append(ExtensionResultItem(icon='images/icon.png',
name=php_bycrypt,
description='PHP BYCRYPT',
highlightable=False,
on_enter=CopyToClipboardAction(php_bycrypt)
))
return RenderResultListAction(items)
if __name__ == '__main__':
EnpassExtension().run()