PowerShell
PowerShell
Example: Crypt2.SetDecryptCert method
Demonstrates how to call the SetDecryptCert method.Chilkat PowerShell Downloads
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"
$success = $false
$cert = New-Object Chilkat.Cert
$success = $cert.LoadPfxFile("c:/pfx_files/my.pfx","password")
if ($success -ne $true) {
$($cert.LastErrorText)
exit
}
$decrypt = New-Object Chilkat.Crypt2
$decrypt.CryptAlgorithm = "pki"
$success = $decrypt.SetDecryptCert($cert)
if ($success -ne $true) {
$($decrypt.LastErrorText)
exit
}
$bd = New-Object Chilkat.BinData
$success = $bd.LoadFile("c:/someDir/pkcs7_encrypted.dat")
$success = $decrypt.DecryptBd($bd)
if ($success -ne $true) {
$($decrypt.LastErrorText)
exit
}
# bd contains the decrypted content.