From 14cfe8618b6184f949a412dc0f37ca3cb097c44b Mon Sep 17 00:00:00 2001 From: Kushal Date: Mon, 10 Aug 2026 18:29:51 +0530 Subject: [PATCH] Fix RandomNumberGenerator.Fill incompatibility with Windows PowerShell 5.1 --- setup.ps1 | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/setup.ps1 b/setup.ps1 index f3d43d31..8d94a2e6 100644 --- a/setup.ps1 +++ b/setup.ps1 @@ -434,7 +434,9 @@ function Configure-Auth { $jwt_key = Read-Host "Enter JWT secret key (leave empty to auto-generate)" if ([string]::IsNullOrEmpty($jwt_key)) { $bytes = New-Object byte[] 32 - [System.Security.Cryptography.RandomNumberGenerator]::Fill($bytes) + $rng = [System.Security.Cryptography.RandomNumberGenerator]::Create() + $rng.GetBytes($bytes) + $rng.Dispose() $jwt_key = [System.BitConverter]::ToString($bytes).Replace("-", "").ToLower() Write-ColorText "Auto-generated JWT secret key." -ForegroundColor "Yellow" } @@ -446,7 +448,9 @@ function Configure-Auth { $jwt_key = Read-Host "Enter JWT secret key (leave empty to auto-generate)" if ([string]::IsNullOrEmpty($jwt_key)) { $bytes = New-Object byte[] 32 - [System.Security.Cryptography.RandomNumberGenerator]::Fill($bytes) + $rng = [System.Security.Cryptography.RandomNumberGenerator]::Create() + $rng.GetBytes($bytes) + $rng.Dispose() $jwt_key = [System.BitConverter]::ToString($bytes).Replace("-", "").ToLower() Write-ColorText "Auto-generated JWT secret key." -ForegroundColor "Yellow" } @@ -547,7 +551,9 @@ function Ensure-InternalKey { $content = if (Test-Path $ENV_FILE) { Get-Content $ENV_FILE -Raw } else { "" } if ($content -notmatch "(?m)^INTERNAL_KEY=") { $bytes = New-Object byte[] 32 - [System.Security.Cryptography.RandomNumberGenerator]::Fill($bytes) + $rng = [System.Security.Cryptography.RandomNumberGenerator]::Create() + $rng.GetBytes($bytes) + $rng.Dispose() $internal_key = ($bytes | ForEach-Object { $_.ToString("x2") }) -join "" "INTERNAL_KEY=$internal_key" | Add-Content -Path $ENV_FILE -Encoding utf8 }