IMS_Blog

Because I forget stuff. Part of norcimo.com

Note: It appears you must have reached this page by a deep level URL. In general this site is currently down and unmaintained. See here

About This Post

Originally posted August 6 2006 at 17:08 under Blogging. 0 Comments. Trackbacks Disabled. Last modified: 06 August 2006 at 18:49

Gobbeldeegoookeeness?

Mood:
Satisfied
Location:
Hidden :-)

Anybody looking at the last entry may think I’ve started talking even more rubbish than usual. It’s actually all due to a post by Vincent Cheung which I came across. I was bored enough to give it ago, though not without adding my own touches of course ;-)

The first thing which struck me about that solution was the need for a unique id for each div surrounding the encrypted text. Now I don’t have a particular desire to mix cypher and plain text in the same post, and my posts are already surrounded by a div. Of course I could generate unique id’s quite easily but it seemed a bit more elegant to simply pass a reference to the decrypt link and work my way back up the DOM to the appropriate div. So that’s what I did.

The javascript can be found here (I don’t claim it’s at all well written). My bit is the decryptPost function at the very end. It takes one parameter which is a reference to the clicked link (which is sent using the this keyword in the link’s onClick event). It then steps up the DOM until it finds the enclosing div and procedes to attempt to decrypt each paragraph in turn. This has a couple of advantages 1) I don’t have to worry about the general formating applied to blog posts by default (i.e. the fact that those paragraphs exist to start with) 2) It means I can actually encrypt different paragraphs with different keys should I wish and then give out a key for pieces I might want seen whilst still keeping some private.

As well as keeping a local copy of the javascript encrypt/decrypt page I also wrote a greasemonkey script to encrypt a blog post with one click. This also automatically adds a nice key (using the previously mentioned Key Values plugin by Brad Cheate) so that the template has a hook to know to add the decryption link.

Anyway, if you want to try it out the super, never to be revealed to the world, secret key to decrypt the the last post is… testkey

Update: I edited the javascript a bit to accept a space separated list of keys and decrypt whatever it can with each in turn.

Comments (0):

Post a comment

Name and email address are required. Email address is never shown. If you enter a URL your name will be linked to it (this and other links will have the rel attribute set to contain nofollow). Markup allowed: <a href="" title="" rel=""> <em> <strong> <abbr title=""> <acronym title=""> <p> <br />. Anything else is stripped; please be valid. Single linebreaks automatically convert to <br />, double to <p>'s. Additionally anything that looks like a bare URL should get automagically linked. Many acronyms and abbreviations are also automagically handled.

Please note this blog's comment policy

Trackbacks (0):

Trackback URL: http://www.norcimo.com/MT/mt-tb.cgi/577

Advanced...

This Crazy Fool

Who:
Dr Ian Scott
Where:
Croydon (and Gateshead), United Kingdom
Contact:
ian@norcimo.com
What:
Bullding Services Engineer (EngDesign), PhD in Physics (University of York), football fanatic (Newcastle United), open source enthusiast (mainly Mozilla)

More about me [Disclaimer]

You may subscribe to IMS_Blog using the RSS Feed, the Atom Feed or by email.

Creative Commons License

From August 06 Other Years

© Ian Scott. Powered by Movable Type 3.2. This blog uses valid XHTML 1.0 Strict and valid CSS. All times are local UK time. For further details see the IMS_Blog about page.. All my feeds in one.