It seems like everything except the 'i' is a prefix, a lot of computing must have went in to generating it.
One tool to do it is called 'Shallot' https://github.com/katmagic/Shallot
The readme includes a table of estimated computing time required. A 15 char prefix like Facebook's is not even on the table, and a 14 char prefix is estimated to take 2.6 million years. There is also a GPU version which should be an order of magnitude faster: https://github.com/lachesis/scallion/blob/gpg/README.md
Also, technically. the onion addresses not public keys, but derived from a public key. It's actually a hash of the public key.
It appears that the hashing algorithm used is SHA1. Source: The last few lines of the easygen function https://github.com/katmagic/Shallot/blob/master/src/math.c