Sample code for 30+ languages & platforms
PowerShell

Use Base64 RSA Key to Encrypt

See more RSA Examples

Loads a Base64 RSA key and uses it to encrypt a string, returning the result in base64.

Chilkat PowerShell Downloads

PowerShell
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"

$success = $false

# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

$pubkey = New-Object Chilkat.PublicKey

$success = $pubkey.LoadBase64("MIICdgIBADA ... A9PXLk+j5A==")
if ($success -eq $false) {
    $($pubkey.LastErrorText)
    exit
}

$rsa = New-Object Chilkat.Rsa

$success = $rsa.UsePublicKey($pubkey)
if ($success -eq $false) {
    $($rsa.LastErrorText)
    exit
}

$rsa.EncodingMode = "base64"

$encryptedStr = $rsa.EncryptStringENC("12345678",$false)

$($encryptedStr)