Hudzilla.org - the homepage of Paul Hudson
Contents > Security concerns > Protecting your data Wish List | Report Bug | About Me ]

17.3.3     Asymmetric vs. Symmetric

This is NOT the latest copy of this book; click here for the latest version.

At the most basic level, each method of encryption can be categorised as being asymmetric or symmetric - either you need one key to encrypt and another to decrypt, or the same key works both ways. Each has their own advantages and disadvantages, as per usual.

Asymmetric encryption, also known as public key encryption, means that you have one key for encryption (a public key) and another key for decryption (a private key). The public key can be given away freely to whoever wants it - after all, with just the public key your data cannot be read, because people would need the private key to decrypt your data. For example, if you sent out your public key to everyone who emails you, they would all be able to send you encrypted emails that only you would be able to decrypt and read.

Symmetric encryption, also known as secret key encryption, means that you have one key for encryption that works also as the key for decryption. The easiest symmetric encryption method to understand is called ROT13, and legend would have us believe it was first used by Julius Caesar to encrypt orders going to Roman troops. ROT13 works by shifting all letters in the alphabet thirteen places to the right - A becomes N, B becomes O, Z becomes M, etc. Because there are twenty-six characters in the English alphabet, performing ROT13 a second time results in the original text again - N becomes A, O becomes O, and M becomes Z.

Symmetric encryption is very easy to use, and usually very fast too. On the other hand, symmetric encryption keys must be kept secure - you would need to make sure each person who needs the key gets it without any risk of it getting out.

Asymmetric encryption is generally slower than symmetric encryption, however the public keys they use are safe to be published anywhere (even on the Internet) because to get the private key from a public key could take hundreds of years of work.





<< 17.3.2 Terms you need to know   17.3.4 Basic symmetric encryption in action: str_rot13() >>
Table of Contents
Want to see this stuff in print? PHP in a Nutshell takes the core topics covered here, adds in thousands of edits from the editorial team and myself, and combines them to make an unbeatable reference for PHP programmers at all levels.



My latest book has hundreds more tips on how to use PHP, Apache, and MySQL, plus Perl, Python, shell scripts, performance tuning, and more!



Top-right shadow
 
Bottom-left shadow Bottom shadow

Comments from other readers
A PHP User - 29 Aug 2008

"O becomes O"...o rly? :)



Add comment
Please note that by posting a comment here you are committing it to the public domain. This is important so that others can make use of your code themselves, and also so that I can incorporate helpful notes directly into the main text. Comments are limited to 2000 characters in length.

If you are reporting an error in the content, please tell me directly.

Your name/email address:
Your comment:
 
Now, in order to verify that you're a real person, please answer this simple question: what is three plus eight?
The answer is:
(please write in
numbers, eg 19)


Top-right shadow
 
Bottom-left shadow Bottom shadow