MD5 is a weak hashing algorithm and can be cracked using rainbow table like with: md5breaker.com
The sha1 hash is generated using java code running on the server, an example of the code is available at: java sha1 The same way, the MD5 hash is processed on the server using java, the code generating the hash is available in this article: MD5 java
Sha1 and Md5 are weak algorithm. It is preferable to use SHA256 or sha512 which have less probability of collition. SHA512 is a variant of the SHA-2 set of cryptographic hash functions. It generates a 128 digit hexadecimal number, where sha1 only generates a 40 digit number. Generate sha 512 using java
MD5 on Wikipedia
SHA-1 on Wikipedia