Re:Run your own OAuth2 server
by machete143 on Monday September 04, 2017 @10:28AM
(#15168425)
Good idea! How could that look like on windows (the guide should work on all OS and I'm no windows pro)?
[ Parent
| on HN ]
Rough equivalent in PowerShell would be:
@(48..57 + 65..90 + 97..122) | Get-Random -Count 32 | ForEach-Object -Begin {$secret = ''} -Process {$secret += [char] $PSItem} -End {$env:SYSTEM_SECRET = $secret; Write-Host "SYSTEM_SECRET is $secret"}My Powershell-fu isn't quite up there. What's the first part of that block? Is that concatenating arrays of ranges of char codes?
Yes, it just creates an array of the decimal values for ASCII A-Za-z0-9. By default Get-Random just returns a random unsigned int, but if you pass in an array of objects it will select a random object from the array.