Powershell Asymmetric Encryption test RRS feed

  • Question

  • From the Powershell console, I enter the following 4 lines one at a time.

    $rsa = New-Object System.Security.Cryptography.RSACryptoServiceProvider(1024)
    $PrivateKey = $rsa.ToXmlString($true)
    $PublicKey = $rsa.ToXmlString($false)
    $OriginalText = "Now is the time."

    How do I test encrypting and decrypting?

    The next 2 lines are pseudo code:

    $EncryptedText = $rsa.Encrypt($OriginalText, $PrivateKey)
    $DecryptedText = $rsa.Decrypt($EncryptedText, $PublicKey)

    Sorry if this is not what the intended use was for asymmetric encryption. But I like the idea of being able to encrypt a string with one key and decrypt it with another.

    Thank you for your help.

    • Moved by Bill_Stewart Thursday, August 28, 2014 7:37 PM Abandoned
    Tuesday, July 8, 2014 3:00 AM

All replies