Store Your Password with Encrypted String

If you want to store your credential into a script, and don’t want others know it, you may need a fake solution: store your password with encrypted string. How? This article tells you how to encrypt your password with base64 encoding.

Encrypt Your Password

It’s an example:


PS C:\User\Chenry> strpwd = "abcdefg" PS C:\User\Chenry> temp = [System.Text.Encoding]::Unicode.GetBytes(strpwd) PS C:\User\Chenry> secpwd = [System.Convert]::ToBase64String(temp) PS C:\User\Chenry> secpwd "YQBiAGMAZABlAGYAZwA="

Decode Your Password

It’s an example:


PS C:\User\Chenry> secpwd = "YQBiAGMAZABlAGYAZwA=" PS C:\User\Chenry> temp = [System.Convert]::FromBase64String(secpwd) PS C:\User\Chenry> strpwd = [System.Text.Encoding]::Unicode.GetString(temp) PS C:\User\Chenry> strpwd "abcdefg"

Enjoy it!

Leave a Reply

Your email address will not be published. Required fields are marked *