As gusano79 said, hash functions are one-way, which makes them perfect for encrypting things like passwords. They are never decrypted, but instead the password a user enters when logging in is hashed. This hash is then comapred with the hash of the correct password which is on record.
If you want to reverse a hash, you'll have to do it indirectly, by undergoing a painstaking operation of brute-forcing it. For example generating strings in a predictable order (a,b,c,d,e,f ... aa,ab,ac .. ba,bb,bc etc.) and hashing each string until the produced hash matches the hash you wanted to reverse. This is extremely expensive (time, electricity used by the computer) so there's really no point.
What gusano79 and assembly guy said. The sources and description of function of the md5 and sha-nnn hash functions are freely available on the web. Here is a link to the md5 article on wikipedia, including very clearly written pseudo-code that should be easily converted to most any computer language. http://en.wikipedia.org/wiki/MD5