This question already has an answer here:
When using web3.js to execute a function in a contract, I always get the following error: "authentication needed: password or unlock." I know that I have to unlock account first via either geth console or web3.personal.unlockAccount(web3.personal.listAccounts,"", duration). However, it is not convenient to use console when the smart contract executes in the real network. Moreover, I am not comfortable to use web3.personal.unlockAccount because I have to provide the password of the account in the clear text. So, what is the best way to unlock account programmatically while still keeping the password secret?