Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add md5 plugin #542

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added PluginDirectories/1/md5.bundle/Icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions PluginDirectories/1/md5.bundle/examples.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
md5 ~str(my-secret-word)
9 changes: 9 additions & 0 deletions PluginDirectories/1/md5.bundle/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "md5",
"displayName": "md5",
"description": "Generate the md5 hash from a word.",
"examples": ["md5 my-secret-word"],
"categories": ["hash", "md5"],
"creator_name": "mrzmyr",
"creator_url": "https://github.com/mrzmyr"
}
59 changes: 59 additions & 0 deletions PluginDirectories/1/md5.bundle/plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
from __future__ import unicode_literals
import json
import urllib

import i18n
import hashlib
import os

def copy_to_clipboard(hashStr):
command = 'printf ' + hashStr.strip() + '| pbcopy'
os.system(command)

def build_html(hashStr):

html = """
<html>
<head>
<style>
body{
padding: 20px;
font-family: 'Helvetica Neue';
line-height: 1.4;
background: #EEE;
text-align: center;
font-weight: 300;
}
.msg {
font-size: 20px;
color: #333;
}
p {
color: #999;
font-size: 18px;
}
</style>
</head>
<body>
<div class="msg">{{hashStr}}</div>
<p>Hit 'return' to copy.</p>
</body>
</html>
"""

html = html.replace("{{hashStr}}", hashStr)
return html

def results(fields, original_query):

md5_str = hashlib.md5(fields['~str'].encode('utf-8')).hexdigest()
html = "<h1>{0}</h1>".format(md5_str)

return {
"title": "md5",
"run_args": [md5_str], # ignore for now,
"html": build_html(md5_str)
}

def run(hashStr):
copy_to_clipboard(hashStr)