From what I think you are having trouble recognizing difference between Encryption and Hashing. Although they are both related to the field of Cryptography, they solves different problems. They both are used to store data securely but how they solve problem varies tremendously.
Key thing to note here is - Hashing is a one-way function, while Encryption is not.
A really simple and secure Hashing algorithm will require a string (or any type of data) as parameter and that is all it needs to create a hashed string (or data). As a sidenote however, in order to increase the security of algorithm they take other parameters like salt. But this can be safely ignored for sake of simplicity. Once you obtain a hashed data, it should be impossible to turn it back into what it actually was (unhashing) because it would defeat the very purpose of hashing it.
Encryption, on the other hand, works both ways. Like hash it's purpose is to scramble the data so no one can read or understand it, but in this case we want the data back. In order to achieve this, there comes another important parameter in the algorithm - the key! This key is used in encryption algorithm (say AES) with data that is to be encrypted to create encrypted data. In this case however, we can retrieve original data with the key that we used.
TL;DR - Both have their own places where it is to be used. Using Encryption adds the responsibility of handling keys properly, whereas Hashing eliminates that hassle at the cost of not being able to retrieve original data back.
More about this - Fundamental difference between Hashing and Encryption algorithms
From what I see you are trying to implement is MD5 Hashing. It's a hashing function which works one way only (as explained above).