# Is this method of salting effective?

So this is my first post on this forum, so bear with me if I sound stupid. I am creating my own web application with JavaScript and MongoDB. I am storing all user information in a Mongo table, and currently this is the hashing algorithm I used to store the passwords:

function generatePassword(input) {
return Buffer.from(crypto.createHash('sha256').update(input).digest('base32')).toString('hex').toUpperCase();
}


So, from what I recall from previous Cyber Security classes, sha256 has been long cracked, therefore deeming it insecure for storing passwords. I understand this being my web application I will not be experiencing security breaches, but I want to show that I have the awareness and knowledge to correctly and securely store the passwords. Therefore, I thought that if I changed up the code a little bit by using this:

function generatePass(input) {
input = input + "455kjnr2902rug5348934";
return Buffer.from(crypto.createHash('sha256').update(input).digest('base32')).toString('hex').toUpperCase();
}


I guess my questions are, is this

a. An effective salting method? If not, how would I go about salting the password? b. Is there a more secure way of doing this? Is this basically useless, or useful?

Thanks in advance to anyone who can help!

• Why is the function called generatePass? Isn't the user supplying the password? – Aman Grewal Jan 18 at 20:52