File size: 703 Bytes
d384f76 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | function New-Base64Secret {
param([int] $ByteLength = 48)
$bytes = [byte[]]::new($ByteLength)
$rng = [System.Security.Cryptography.RNGCryptoServiceProvider]::new()
try {
$rng.GetBytes($bytes)
}
finally {
$rng.Dispose()
}
[Convert]::ToBase64String($bytes)
}
function New-HexSecret {
param([int] $ByteLength = 32)
$bytes = [byte[]]::new($ByteLength)
$rng = [System.Security.Cryptography.RNGCryptoServiceProvider]::new()
try {
$rng.GetBytes($bytes)
}
finally {
$rng.Dispose()
}
-join ($bytes | ForEach-Object { $_.ToString("x2") })
}
"JWT_SECRET=$(New-Base64Secret)"
"TOTP_ENCRYPTION_KEY=$(New-HexSecret)"
|