Skip to content

Instantly share code, notes, and snippets.

@RaccoonDev
Created December 17, 2015 09:40
Show Gist options
  • Save RaccoonDev/4b3fcc34be55e7633e66 to your computer and use it in GitHub Desktop.
Save RaccoonDev/4b3fcc34be55e7633e66 to your computer and use it in GitHub Desktop.
Generate secure byte array and encode it with base64 string.
param(
[int]$SecretArrayLength = 64
)
$randomNumberGenerator = [System.Security.Cryptography.RandomNumberGenerator]::Create();
$ba = [Byte[]] (,0 * $SecretArrayLength);
$randomNumberGenerator.GetBytes($ba, 0, $SecretArrayLength);
return [System.Convert]::ToBase64String($ba);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment