From an information security perspective, you should consider your scheme public, as per Kerchkoff's principle, even more so since you disclosed your source code. Thus the security of your generated password are reduced to the security of their input. The algorithm chosen is irrelevant as an attacker would choose the input and use your algorithm to generate the password.
So let's evaluate the security of your inputs:
- Master password: If an attacker find it, all your passwords are compromised. Do not reuse your passwords.
- Site name: This is public knowledge, it doesn't increase security.
- Password length: Contains very few entropy. It's almost useless.
- Available characters: I guess you always use the same ones or use all the characters allowed by the website, as doing otherwise would be very inconvenient. Thus it is equivalent as a second small master password.
So, basically your scheme hash public information with a master password. An attacker only needs to successfully brute-force one of your generated passwords to recover your master password and then be able to easily find the other generated passwords.
A better solution would be to randomly generate your passwords. This way, they cannot leak information about the others. You could then save them in an encrypted file or database. You would only need to remember the master password of encrypted database, without having to remember the password length or how the website was called before they changed their name. Password managers allow you to do just that.