depends on page design... */ /* li right margin may exceed p right margin! */ } table { border-collapse: collapse; } table tr { vertical-align: baseline; } table td { padding-right: 0.4em; /* give all tables some spacing between cells */ } ul { margin-top: -0.5em; margin-bottom: 0.5em; margin-left: 3.2em; margin-right: 0em; list-style-type: disc; list-style-image: url(../images/listbullet.gif); list-style-position: outside; } li { max-width: 64em; /* broadly matches max-width on p */ } img.right { float: right; } img.floatRight { float: right; } img.floatLeft { float: left; } /* even line spacing with sub/superscripts: www.cs.tut.fi/~jkorpela/www/linespacing.html */ sup, sub { vertical-align: 0; position: relative; } sup { bottom: 1ex; } sub { top: 0.8ex; } hr { color: #cccccc; background: #A2A2A2; height: 2px; border: 0; } hr.fullwidth { /* rule running into margin */ margin-left: -120px; } a { color: #993300; /* brick red */ font-weight: bold; text-decoration: none; } a img { border: 0; } .small { font-size: 66%; } a:visited { font-weight: normal; } a:hover { text-decoration: underline; } /* over-ride 'a' when inside h2 */ h2 a { color: #333333; font-weight: normal; } /* over-ride 'a:visited' when inside h2 */ h2 a:visited { color: #333333; } .margin { margin-left: -150px; } tr.tableRule td { border-top: 2px solid #CCCCCC; } /* scripts pages */ pre { font-family: "Lucida Console", "Courier New", Courier, monospace; font-size: 0.8em; line-height: 1.4; margin-left: 1cm; margin-top:0; } pre.fullwidth, p.fullwidth { /* use margin to get full width of page */ margin-left: -80px; } .note { font-size: 1.1em; line-height: 1.5; } .small-caps { font-variant: small-caps; } code, .code { /* in-line code frags */ font-family: "Lucida Console", "Courier New", Courier, monospace; font-size: 0.9em; } .align-right { text-align: right; } /* validation */ label.error { color: #990000; font-style: italic; margin-left: 1em; } input.error { border: 1px dotted #990000; } span.rtl { /* obfuscate email */ unicode-bidi: bidi-override; direction: rtl; white-space: nowrap; } /* suppress left margin for printing */ @media print { body { padding-left: 0; } div#header { margin-left: 0; } div#header img { display: none; } pre.fullwidth { margin-left: 0; } } ### - Javascript Encryption series: webpages to encrypt things from your little brother or sister.
Password:
Text:
Block TEA (xxtea) Javascript by Chris Veness


What is this?
This is a modified version of the webpage written by Chris Veness. It runs a javascript version of BLOCK TEA (XXTEA), a MEDIUM strength encryption algorithm. The original TEA algorithm was strengthened and goes under the name of BLOCK TEA (XTEA). The third version is even more secure and is also known as CORRECTED BLOCK TEA (XXTEA).
It is straight forward to use. Put in a password, and then some text. Press the "Encrypt it" button and you will get the cipher-text. To decode a message, paste the cipher-text into the third window (from the top), and then click on the "Decrypt it" button.
*It should run anywhere from the internet. Theoretically, if you save this page locally, it should still work offline, ie, even without an internet connection.
*It accepts Unicode text. So there is a high chance of it being able to encrypt an unusual text character or character of a different language.

What are the limits of this webpage?
*The password is 16 characters or less
*The message does NOT retain its line/carriage returns. It treats line returns as a "space".
Just to clarify: There is nothing wrong with the scripts. The original webpage is a demonstration. It is because I do not have the coding skills to modify them to accept carriage returns, to change the height of the data windows to be compatible with carriage returns and "word wrapping", or to change the length of the passwords.
*The Copyright © holders have all rights reserved. The software and web documents are provided "as is" without express or implied warranty of any kind by the parties and contributors involved.
(†) Webpage formatting by JCPMA © 2011

Wikipedia links
http://en.wikipedia.org/wiki/XXTEA
http://en.wikipedia.org/wiki/XTEA
http://en.wikipedia.org/wiki/Tiny_Encryption_Algorithm

Chris Veness' original xxtea
http://www.movable-type.co.uk/scripts/tea-block.html

... Wheeler & Needham’s Tiny Encryption Algorithm is a simple but powerful encryption algorithm (based on a ‘Feistel cipher’).

This is a JavaScript implementation of the (corrected) ‘Block TEA ’ or ‘large block’ version of the algorithm (also dubbed ‘xxtea’) which operates on variable-sized blocks, as opposed to the 64-bit blocks of the original.

This is a simple but highly effective DES-style encryption algorithm which can be useful for web applications which require security or encryption. It provides very secure cryptographically strong encryption in concise, clear JavaScript code.

The Block TEA version is faster than the original (64-bit block version) when encrypting longer blocks (over 16 chars), and is more secure (‘a single bit change will change about one half of the bits of the entire block, leaving no place where the changes start’). It is also simpler to implement in JavaScript for encrypting arbitrary-length texts (being variable block size, it requires no ‘mode of operation’). For an implementation of the original algorithm, see tea.html.

TEA uses a 128-bit key, which could (for increased security) be an encrypted (or hashed) form of the supplied password. Here I simply convert the first 16 characters of the password into longs to generate the key. The password might be a user-supplied password, or an internal system password. A system password will be more secure if it avoids plain-text (e.g. ‘dVr4t%G§Uu+mz7+8’).

I needed to encrypt text, not binary data, so I have built on this so that it operates on text rather than just on numeric arrays, and also rearranged it slightly so that p is not referenced outside the for loop (valid in C, but not always in other languages). The ciphertext is encoded as Base64 so that it can be safely stored and/or transmitted without troublesome control characters causing problems. The plaintext is first converted to UTF-8 so that the script is multi-byte-character safe.

Speed: using IE on a 3GHz P4 the script processes around 80kB/sec (around 25 pages of text), though it slows down with longer texts.

...

For an explanation of the operation of the TEA algorithm, and cryptography in general, an excellent book is Information Security Intelligence: Cryptographic Principles & Applications by Tom Calabrese (available from Amazon.com). There is also a good article explaining TEA operation and cryptanalysis by Matthew Russell from York University and a short article in Wikipedia.

Note: if you are interested in cryptanalysis of TEA, bear in mind that there are 4 versions described in 3 documents: the original TEA, then Extensions to TEA (addressing weaknesses in TEA and also describing Block TEA), and Corrections to Block TEA (aka xxtea). This page implements the last of these.

If you want industrial-strength encryption, I have also implemented a version of AES.
...

© 2005-2010 Chris Veness - www.movable-type.co.uk