I use my blog as literally an online journal to record my activities and thoughts so I can look back at them later. Writing things down can also be therapeutic. As a side benefit, it serves as a form of communication with my friends and randoms (it helped me get my apartment).

The problem is that I have to constantly censor myself as I do not want other people reading some of my more personal thoughts, especially ones about people that read my blog. I want my blog to be public, but I want to also add some private text.

My solution is to use cryptography. I will encrypt text I don't want people to read, this way the text is not available anywhere (not even on the server). The difficulty is in making it easy to do both encryption and decryption and doing so in a secure manner, i.e. do everything locally.

I then modded the code to do dynamic text with CSS. The result is the little demo at the top. When you enter the key into the prompt box, it decrypts the scrambled text on the fly without reloading the page! Better yet, it's all done locally, so not even the server ever sees the plain text.

Note 1: "unique_name" is the ID of the div (it appears in both lines of code) and ID's, have to be unique. In other words, if you use this code multiple times for multiple blocks of encrypted text, you have to change "unique_name" to "encrypted", "encrypted2", "encrypted_text_about_bob", etc. because the same name cannot be used twice.

The encrypted text is secure as long as you keep the key secret. The key is like a super-ultra secure password. You can use the same key over and over for multiple encryptions (so you don't have to remember/store multiple keys). If you want select people to see the encrypted text, you can give them the key. You may want to use a set of keys, one for super private, one for the gf, one for close friends, etc.

FAQ

Is this secure?

Yes, the encryption used is very secure.

Is there a back door? Can you read my encrypted text?

No. No one without the key can read the encrypted text and I don't know how to make a good back door.

Is this going to install bad stuff on my computer or break stuff? Is this adware crap? Is this a virus?

No. I don't know how to do that.

I lost the key, can you help me decrypt the text?

No. You lose the key and there's pretty much no way to decrypt the text, that is, until we get quantum computers.

Do you have a quantum computer?

Yes, but I don't know how to use it.

Disclaimer: Not to be used if encryption is illegal in your country or used for illegal purposes.

maybe you could help me with another question:is there a way to hide the code in the post in a way the decrypted text will expand by entering the right pass and the encrypted cypher-code isn't displayed at all in the blog?

I was thinking of doing a combination decrypt and show thing, but have been debating whether I want to actually do that. In some respects, I like having all the encrypted text show so that I can see how much text there is, but then it is annoying to have it all appear on the page.

It should be pretty easy to do, just involve some css to show/hide the div, like how I do the show/hide comments.

You could either A) leave it visible, but with a small font size (4pt or so?) to still be able to see the general length, or B) get a bit more complicated and hide the cyphertext but display "[43 lines encrypted]" or something.

Is there a way to apply this process within a web mail page? I don't to want to secure my mail traffic, I just want to encrypt the content of my inbaox and other folders within the web mail, like yahoo, hotmail, gmail, etc. so that search bot can't search for key words or email addresses, etc. Can I do that with greasemonkey extension with firefox?

Theoretically you could implement the encryption / decryption using JavaScript bookmarklets. "Replace the selected text with the en/decrypted text", for instance, would be relatively doable and would work with any webmail system without requiring Greasemonkey.

Of course, you could just use a blogging service like livejournal which actually has multi-leveled privacy on it's blog posts. You can set your posts so they're visible by only your friends, or sub-groups of your friends or by nobody else.

I created a JavaScript extension with this in mind; encrypting text just by selecting it from a website, very useful for blooger or just crypto fans like me. It's called Pescadito and even do it's super beta I believe it's pretty good, you can downloaded from here http://crackx.webcindario.com/down.php?cat=3

Nope, the key is not stored anywhere. The javascript encryption is done entirely on the client side in your web browser without any communication to any servers. Try it. Download the page to your own computer and encrypt something while not connected to the Internet.

Hi!Just one question to this remarkable script:Will the encryption page always be online - what kind of encryption do you use, that I can still use your script, even when the default encryption site no longer exists...best regards,Chris

I intend on keeping the encryption page up. If you want, you can save it to your own computer and it will still work as all the encryption happens locally on your computer and not on any servers or anything. You can (and should) also save the javascript code for decryption on your own server, so then you are wholly independent of whether or not I keep the material online. The encryption is 256-bit AES, which is the standard encryption used by the US government.

hi! thanks for this code tutorial thing..im trying to use it for my site..and im kinda stuck =[wen iv encrypted my text wer do i put it? and i dont understand the div id thing..pls help me! i really wanna use it..thanks again!

Hello. I have no idea what I am doing with this and have been working on it most of the afternoon. Can you please explain where the encryption script goes and the template to decrypt. This is great and just what I need badly. If you have the time i would greatly appreciate it. i am using the simple ii template for the blog. i have never worked with html and have been looking for an example.

I get it alright till the last step...when i publish the post, it does not open the dcryption window like it does in yours. There's just no decryption window there:( All i can do is to keep on clicking on this unresponsive link....

Hi,it was a nice post on encyption.I tried to do as you have mentioned in step 1,2 and 3. But after posting the link for decryption does not work :(((also do not knowwhere to include the step2 int the blog header??can u elaborate that.my blogsite is http://paneerkadhai.blogspot.com

I am killin' Myself trying to figure out where to paste that decryption key, etc., into the blogger header. Could you please email Me? I need help. I really want to use this super-cool encryption for secret messages to My slaves. Mistress.Grace@yahoo.com - thanks!

I'm trying to do something a bit simpler, but I feel as if this is the right code to begin with. Nonetheless, I could use a clue. Here's what I'm trying to accomplish:

1. User comes to "buy the book" page, where there is a text field for a courtesy code.

2. If the user enters the correct courtesy code and clicks the Submit button, the price reflected on the next page is price A.

3. If the user enters the incorrect code, the error is trapped and the user is offered the chance to correct the code or clear the box.

4. If the user leaves the box blank and clicks the Submit button, the price reflected on the next page is price B.

Because this is the last piece of the site I'm building and the rest is all in JavaScript, I'd like to do this client-side.

My thinking was that I'd encrypt the correct courtesy code once, then compare the result with the user's result. But I see that every time I click the encrypt button on the demo site (http://www.psi.toronto.edu/~vincent/blog/jscrypt.html), the cipher text is different. So my plan isn't going to work the way I thought.

Weird thing is i can get "Demo 1: Encrypted text shown" to work but not "Demo 2: Encrypted text hidden"i view source and went through your template, i've got my codes done the same way you did but the decryption link doesn't show up.

Hi Vincent,This script is great. I am looking for a way to encrypt on the server (in php) and decrypt at the client (in javascript). Is this encryption algorithm self made? If so, could you also share a module to do so at the server in php? It would be of great help to many, especially in these AJAX days.

But, wouldn't be more interesting if it used to encrypt a web site source code? Does it do anythink like that?

Im looking for a program to encrypt my blog code without interupts anything or to block the source code button and not showing the source code of my blog, im afraid that maybe someone will notify it, maybe a hacker...who knows!!

Not sure whether is this post still active but i tried out and it does not seem to work. I can get the prompt to ask me enter the key. But regardless of what i enter, it always say:"INVALID DECRYPTION KEY!" I did input the correct key though. Wonder what went wrong. I am using IE and wondering is this the problem? i am stuck.... :(:(:(:(:(

I just had to drop a line and say thank you for this bit of code! I just used it because it's entirely client-side encryption/decryption so I don't have to trust anyone with the hidden text. Not even you, the coder of what I'm using! It's exactly what I was looking for, but it is so nicely made I'm sure this won't be a one time use. I'll be sure to always give you some credit in html comments ;) so any intrigued coder will know who to go to.

Hi, could you help me with this please? I did the steps like you said but when i posted it, the decryption window like it does in yours. There's just no decryption window there :( All i can do is to keep on clicking on this unresponsive link.

Hi!First of all congrats to Your great work.I would just ask if it´s possible to use your JS Encryption code onhttp://www.tumblr.comI tried to integrate your code at the template, but the postings might not allow JavaScript links...????I really would love to use it with Tumblr blog posts!Best regards,Chris

Hi Vincent, I tried your code, Its working fine.but when I post in in my blog and put my password.it shows invalid password.I dont know why its happening.I have tried many a times.but no go...please help me.ThanksVibhor

Hi Mr,I used ver.2.0, but I don't know what to do to keep the colour of text and line break for my secret massage. I don't want seclect it as one line. So would you please guide me what will I have to do? Thank you!