Version 25 of encryption

Updated 2004-10-06 13:38:45

Encryption is the act of applying an algorithmic transformation to two pieces of data (known as the plain text and the key) and producing a single piece of data (known as the cypher text) from which it is not easy to recover either the plain text or the key even if the algorithm used is known. Reversing the process (getting the plain text from the cypher text, with the input of a suitable key) is known as decryption.

There are two main categories of cryptographic systems: symmetric and asymmetric. In a symmetric cryptosystem, the same key is used to encypher as is used to decypher; obviously, letting an untrusted third-party find the key in such a scheme would be catastrophic, but symmetric systems have the advantage that they tend to offer reasonably good performance. The other main category is asymmetric cryptosystems where keys come in pairs, and anything that is encrypted with one key of the pair can be decrypted with the other key of the pair; this makes them fairly useful for situations involving identities, as one of the keys can be kept completely secret (it is usually called the private key) and the other key is made widely available and can be used by anyone (and is usually called the public key.)

Digital signatures are essentially hashes of a text that have been encrypted by someone's private key. Checking the signature for validity is then a matter of computing the hash and testing that it equals the value that you get by decrypting the signature. For various reasons, governments are much happier about digital signatures than general cryptography, even though the underlying algorithms are often pretty much the same.

Protocols like SSH and SSL work by using public-key (asymmetric) cryptography to establish a session-key (i.e. limited lifespan symmetric key) that is used for encrypting the main data streams. Using the private key rarely helps keep it secret, and using a session-key also speeds up comms (symmetric keys tend to be far quicker to handle.)

Note that most modern cryptosystems also use compression; naive encryption of human languages otherwise leaves routes for attack based on frequency analysis.

Note also that for most asymmetric encryption systems, encrypting your data with key A and then encrypting the result with key B is effectively equivalent to encrypting your data with key C, where key C has the property of being much less secure than either key A or key B.


Cryptography resources on the Wiki include:

  • Simple substitution algorithms, such as Caesar and rot13 - these are trivial to break, and there is a page devoted to solving cryptograms.
  • Other (insecure) algorithms of historical interest, such as vignere (a misspelling of Vigenere) and Matrix multiplication and encryption. The page entitled Encryption and decryption has another implementation of Vigenere.
  • A wide range of implementations of modern algorithms, such as those used in PGP. One popular one is blowfish, which appears in the trfcrypt module of trf, in tls, and in security:encrypt and security:decrypt. Also tcllib has an implementation of RC4
  • Encrypted socket communications via SSL can be done with tls and with the trfcrypt module of trf.
  • A related topic is the use of cryptography for digital signatures and for detection of tampering of files. Popular algorithms include sha1 and md5, both of which are implemented in trf and tcllib.
  • One-way hash functions are widely use for purposes like hiding passwords. Michael A. Cleverly has posted an implementation of crypt in pure Tcl that is suitable for this purpose. tcllib provides md5crypt which creates MD5 hased passwords as used in more modern *nix systems. Also compatible with Apache's htpasswd command.
  • Huffman coding, part 2 can offer a step towards compressing encryption, if you don't transmit the map
  • A Tcl des implementation.

Category Cryptography | Category Concept | Category Security