From b5e557329c777138bc6733311c128b42f0ab8e10 Mon Sep 17 00:00:00 2001 From: Reditus Date: Wed, 13 May 2026 20:10:39 +0100 Subject: [PATCH] fix: password hashing via temp script to handle special characters --- setup.ps1 | 10 +++++++++- setup.sh | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/setup.ps1 b/setup.ps1 index 1eaaffb..0fca360 100644 --- a/setup.ps1 +++ b/setup.ps1 @@ -529,7 +529,15 @@ $secret = -join ((65..90) + (97..122) + (48..57) | Get-Random -Count 32 | ForEac # Hash the password using Argon2 Write-Host " Hashing password with Argon2..." -ForegroundColor Yellow -$hashResult = python -c "from argon2 import PasswordHasher; ph = PasswordHasher(); print(ph.hash('$AuthPass'.replace('`$','').replace(\"'\",\"\").replace('\"','')))" 2>$null +$pwScript = @" +import sys +from argon2 import PasswordHasher +ph = PasswordHasher() +print(ph.hash(sys.argv[1])) +"@ +$pwScript | Out-File -FilePath "$env:TEMP\hash_pw.py" -Encoding utf8 -Force +$hashResult = python "$env:TEMP\hash_pw.py" $AuthPass 2>$null +Remove-Item "$env:TEMP\hash_pw.py" -Force -ErrorAction SilentlyContinue if ($hashResult -and $hashResult -match '^\$argon2') { $AuthHash = $hashResult.Trim() Write-Host " Password hashed successfully." -ForegroundColor Green diff --git a/setup.sh b/setup.sh index 60fae11..79c67ff 100644 --- a/setup.sh +++ b/setup.sh @@ -369,7 +369,15 @@ SECRET=$($PYTHON -c "import secrets; print(secrets.token_hex(32))") # Hash the password using Argon2 echo " Hashing password with Argon2..." -AUTH_HASH=$($PYTHON -c "from argon2 import PasswordHasher; ph = PasswordHasher(); print(ph.hash('$AUTH_PASS'))" 2>/dev/null) +PW_SCRIPT=$(mktemp /tmp/hash_pw.XXXXXX.py) +cat > "$PW_SCRIPT" << 'PYEOF' +import sys +from argon2 import PasswordHasher +ph = PasswordHasher() +print(ph.hash(sys.argv[1])) +PYEOF +AUTH_HASH=$($PYTHON "$PW_SCRIPT" "$AUTH_PASS" 2>/dev/null) +rm -f "$PW_SCRIPT" if [[ "$AUTH_HASH" == \$argon2* ]]; then echo " Password hashed successfully." else