Skip to content

Instantly share code, notes, and snippets.

@davefunkel
Last active July 28, 2022 19:58
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save davefunkel/5b7ac7d478596dd00747929d88b50395 to your computer and use it in GitHub Desktop.
Save davefunkel/5b7ac7d478596dd00747929d88b50395 to your computer and use it in GitHub Desktop.
# Generate a random AES Encryption Key.
$AESKey = New-Object Byte[] 32
[Security.Cryptography.RNGCryptoServiceProvider]::Create().GetBytes($AESKey)
# Store the AESKey into a file. This file should be protected! (e.g. ACL on the file to allow only select people to read)
Set-Content $AESKeyFilePath $AESKey # Any existing AES Key file will be overwritten
$password = $passwordSecureString | ConvertFrom-SecureString -Key $AESKey
Add-Content $credentialFilePath $password
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment