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

Fix AES encryption/decryption scripts #16

Open
wants to merge 3 commits 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
6 changes: 4 additions & 2 deletions Commands/Decrypt selection.plist
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env bash
STD_IN=$(</dev/stdin)

[[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] &amp;&amp; . "${TM_SUPPORT_PATH}/lib/bash_init.sh"

get_pw () {
ruby18 -rui -e"print TextMate::UI.request_secure_string(:title =&gt; 'Decrypt AES 128 Encrypted Text', :prompt =&gt; '$1', :button1 =&gt; '$2', :button2 =&gt; 'Cancel').to_s"
ruby18 -rui -e"print TextMate::UI.request_secure_string(:title =&gt; 'Decrypt AES 256 Encrypted Text', :prompt =&gt; '$1', :button1 =&gt; '$2', :button2 =&gt; 'Cancel').to_s"
}

pw=$(get_pw 'What is the password?' Decrypt)
[[ -z "$pw" ]] &amp;&amp; exit_discard

if ! openssl enc -d -aes128 -base64 -pass "pass:$pw"; then
if ! echo -n "$STD_IN"|base64 --decode|openssl enc -d -aes256 -md sha512 -pass "pass:$pw"; then
exit_show_tool_tip
fi
</string>
Expand Down
6 changes: 4 additions & 2 deletions Commands/Encrypt selection.plist
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env bash
STD_IN=$(</dev/stdin)

[[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] &amp;&amp; . "${TM_SUPPORT_PATH}/lib/bash_init.sh"

get_pw () {
ruby18 -rui -e"print TextMate::UI.request_secure_string(:title =&gt; 'Encrypt Text With AES 128', :prompt =&gt; '$1', :button1 =&gt; '$2', :button2 =&gt; 'Cancel').to_s"
ruby18 -rui -e"print TextMate::UI.request_secure_string(:title =&gt; 'Encrypt Text With AES 256', :prompt =&gt; '$1', :button1 =&gt; '$2', :button2 =&gt; 'Cancel').to_s"
}
pw1=$(get_pw 'What password should be used?' Continue)
[[ -z "$pw1" ]] &amp;&amp; exit_discard
pw2=$(get_pw 'Enter password again to verify.' Encrypt)

if [[ "$pw1" == "$pw2" ]];
then openssl enc -e -aes128 -base64 -pass "pass:$pw1"
then echo -n "$STD_IN"|openssl enc -e -aes256 -md sha512 -pass "pass:$pw1"|base64
else exit_show_tool_tip 'Password mismatch! Please play again.'
fi
</string>
Expand Down