Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Recipe 12. Add AppleScript Support > Step 11: Add Custom Object-First Commands—...

Step 11: Add Custom Object-First Commands—Encrypt and Decrypt

The final commands you will implement in this recipe are two object-first commands, encrypt and decrypt. These operations are appropriate for an object-first approach because they apply to a single diary entry and they reverse its state with relatively little overhead.

I embarrass myself here by using the ROT13 algorithm, a simple Caesar or substitution cipher that offers no meaningful security. Since the ROT13 algorithm is reversible, you actually only need a single command, encrypt, because applying it a second time decrypts the text. I implement both methods because you would need both if you used a nonreversible algorithm—for example, a Caesar cipher that shifts the alphabet by some number other than 13.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial