Here’s the fixed version of the script:
<#
.DESCRIPTION
Decrypt all entries from Duplicacy keyring on Windows.
Must be run as the same Windows user that created the keyring.
#>
param (
[Parameter(Position = 0, ParameterSetName = "path")]
[string]$keyringPath = "$env:USERPROFILE\.duplicacy\keyring",
[Parameter(Mandatory, ValueFromPipeline, ParameterSetName = "object")]
[hashtable]$hashTable
)
if ($PSCmdlet.ParameterSetName -eq "path") {
Write-Verbose "Reading keyring from $keyringPath`n"
$stringData = Get-Content $keyringPath
$hashTable = $stringData | ConvertFrom-Json -AsHashtable
}
function Convert-And-Decrypt([string]$base64String) {
$bytes = [System.Convert]::FromBase64String($base64String)
$decrypted = [System.Security.Cryptography.ProtectedData]::Unprotect(
$bytes,
$null,
[System.Security.Cryptography.DataProtectionScope]::CurrentUser
)
return [System.Text.Encoding]::UTF8.GetString($decrypted)
}
$convertedHashTable = $hashTable.Clone()
foreach ($key in $hashTable.Keys) {
$convertedHashTable[$key] = Convert-And-Decrypt $hashTable[$key]
}
$convertedHashTable
And yes, it looks like password
was for the default storage (b2), while STORAGE_password
was for my sftp storage. Thank you!