This following AppleScript code will take the contents of your clipboard and will give you the option to base64 encode or decode its content. It will then set the clipboard to the result.
This little utility is especially handy, for instance, base64 encoding an “easy to guess” password and using that as a login password while registering or creating a membership for a website.
property defaultAnswerEncrypt : "Encrypt Me"
property defaultAnswerDecrypt : "Decrypt Me"
if (the clipboard) ≠ "" then
set {defaultAnswerEncrypt, defaultAnswerDecrypt} to ¬
{the clipboard, the clipboard}
end if
activate
set dialogOne to display dialog ¬
"Would You Like To Encode Or Decode Your
Text Or Phrase?" buttons {"Cancel", "Decode", "Encode"} ¬
default button "Encode" cancel button "Cancel" with title ¬
"Base64 TEXT ENCODER - DECODER" with icon 2 ¬
giving up after 90
if button returned of dialogOne is "Decode" then
activate
set decryptThis to text returned of (display dialog ¬
"Insert The Text Or Phrase You Would Like To Decode" default answer ¬
defaultAnswerDecrypt & linefeed buttons {"Cancel", "Decode"} ¬
default button "Decode" cancel button "Cancel" with title ¬
"Base64 TEXT ENCODER - DECODER" with icon 1 giving up after 90)
set decryptedText to do shell script "echo " & quoted form of decryptThis & " |base64 -D"
set the clipboard to decryptedText
activate
display alert "Your De-Crypted Text Has Been Copied To Your Clipboard" message ¬
decryptedText & " ..is your de-crypted text" buttons {"OK"} ¬
default button "OK" giving up after 10
else if button returned of dialogOne is "Encode" then
activate
set encryptThis to text returned of (display dialog ¬
"Insert The Text You Would Like To Encode" default answer ¬
defaultAnswerEncrypt & linefeed buttons {"Cancel", "Encode"} ¬
default button "Encode" cancel button "Cancel" with title ¬
"Base64 TEXT ENCODER - DECODER" with icon 1 ¬
giving up after 90)
set encryptedText to do shell script "echo " & quoted form of encryptThis & " |base64"
set the clipboard to encryptedText
activate
display alert "Your Encrypted Text Has Been Copied To Your Clipboard" message encryptedText & ¬
" ..is your encrypted text" buttons {"OK"} ¬
default button "OK" giving up after 10
end if