5 ms·
I'd suggest using something like: export SYSTEM_SECRET=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) echo "SYSTEM_SECRET is $SYSTEM_SEC
by tempay 9y ago
I'd suggest using something like:
export SYSTEM_SECRET=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
echo "SYSTEM_SECRET is $SYSTEM_SECRET"
- machete143 9y agoGood idea! How could that look like on windows (the guide should work on all OS and I'm no windows pro)?
- casselc 9y agoRough 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"}
- koolba 9y agoMy Powershell-fu isn't quite up there. What's the first part of that block? Is that concatenating arrays of ranges of char codes?
- casselc 9y agoYes, 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.
- tinus_hn 9y agoNote that Get-Random is not cryptographically secure, it's just seeded by the time stamp of the start of the session.
- drusepth 9y agoLinux noob here: what's the fold for? How is that secret different from doing something like tr -dc A-Za-z0-9_ < /dev/urandom | head -c 32 ?
- koolba 9y agoThe difference is that fold will add a trailing newline. Another option is to add an '; echo' at the end of the operation. And yes the "cat" is not necessary.