Skip to content

Instantly share code, notes, and snippets.

@gregjhogan
Created July 29, 2017 07:00
Show Gist options
  • Select an option

  • Save gregjhogan/f04330fd29847675b2d35b8bb66fd7a0 to your computer and use it in GitHub Desktop.

Select an option

Save gregjhogan/f04330fd29847675b2d35b8bb66fd7a0 to your computer and use it in GitHub Desktop.
Generate a cryptographic key or secret
$aesManaged = New-Object "System.Security.Cryptography.AesManaged"
$aesManaged.Mode = [System.Security.Cryptography.CipherMode]::CBC
$aesManaged.Padding = [System.Security.Cryptography.PaddingMode]::Zeros
$aesManaged.BlockSize = 128
$aesManaged.KeySize = 256
$aesManaged.GenerateKey()
[System.Convert]::ToBase64String($aesManaged.Key)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment