ScriptLife

  • Learn AppleScript
  • About me
  • Archive
  • RSS
  • Ask me anything

Encrypt and Decrypt text through AppleScript

If you want an easy way to encrypt and decrypt text using a passphrase, this may be something for you. I’ve written a Java command line tool using Jasypt (an open source library for encryption) that you can call from your AppleScripts.

  1. Download the Jar file.
  2. Call it from your AppleScript using a “do shell script” command like this:

-- Encrypt text
set textToEncrypt to quoted form of "Wanna know a secret?"
set passphrase to quoted form of "OurSecretPhrase"
set encryptCommand to "/usr/bin/java -jar /path/to/TextCrypt.jar encrypt " & textToEncrypt & " " & passphrase
set encryptedText to do shell script encryptCommand

-- Decrypt text set
textToDecrypt to "Some∞™¶©©«‹Gibberish"
set passphrase to "OurSecretPhrase"
set decryptCommand to "/usr/bin/java -jar /path/to/TextCrypt.jar decrypt " & textToDecrypt & " " & passphrase
set decryptedText to do shell script encryptCommand

To make it extra convenient, you can use Automator to set up services to encrypt and decrypt with just one keystroke. If you need help setting up a Service workflow in Automator, leave a comment and let me know.

    • #encryption
    • #applescript
    • #java
  • 1 year ago
  • 1
  • Comments
  • Permalink
  • Share
    Tweet

1 Notes/ Hide

  1. wozwas likes this
  2. scriptlife posted this

Recent comments

Blog comments powered by Disqus
← Previous • Next →

Logo

About

The adventures of a scripter learning the trade. Currently I'm focused on AppleScript and Unix. I'm also learning Java and Cocoa / Objective-C but this blog is focused on scripting.
  • RSS
  • Random
  • Archive
  • Ask me anything
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr