fix: password hashing via temp script to handle special characters

This commit is contained in:
Reditus committed 2026-05-13 20:10:39 +01:00
1 parent 99864b4d8f
commit b5e557329c
2 files changed
+18 -2

No files matched your search

+9 -1
View File
@@ -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
+9 -1
View File
@@ -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