Store encrypted passwords in a text file
I've tried numerous times to get a service account password into an encrypted file and then recall it. Sometimes it's worked, sometimes not. I hit on a few posts that dialed me into a process that seems to work reliably. The result is below. Its a standalone test script but can be easily imported into any script. What I do is use an XML file as a config file and read it when a script starts. The encoded string this script creates is suitable for storage this way and recalls cleanly. I also include the encrypted AES key in the XML file so both can be read and the internals of the calling script can remain generic. This recovered password can be de-crypted by anyone not just the user who encrypted it so it works fine for service accounts running automated scripts. The script stays in whatever folder you put it in so it's best to put it in a new empty folder for testing. Now for the usual disclaimer... This is only nominally secure. Anyone...