How to encrypt my password that I assign in global variable?

Found a guide : Is there any way to store passwords in encrypted format in global variables?

Thanks!