Security for password

I am doing a simple task of entering account, password and then logging into a website, however, I found an issue that if I save the password in a variable and pass it in, the password is easily leaked. Can anyone advise me on how to work with these types of account, password in a more secure way? Thank you