Crypto.RSADecrypt

From Xojo Documentation

Method

Crypto.RSADecrypt(Data As MemoryBlock, PrivateKey As String) As MemoryBlock

New in 2013r4

Supported for all project types and targets.

Decrypts data using the specified key, which is either a private or public key.

Sample Code

Decrypt a message:

Var privateKey As String
Var publicKey As String

If Crypto.RSAGenerateKeyPair( 1024, privateKey, publicKey ) Then
// 1024-bit private and public keys were generated

Const kMessage = "this is a test"

Var msg As New MemoryBlock(14)
msg.StringValue(0, 14) = kMessage

// Encrypt msg using the publicKey
Var encryptedData As MemoryBlock = Crypto.RSAEncrypt( msg, publicKey )

If encryptedData <> Nil Then
MessageBox("Successfully encrypted.")

// Now decrypt
Var decryptedData As MemoryBlock = Crypto.RSADecrypt( encryptedData, privateKey )
MessageBox("DecryptedData=" + decryptedData.StringValue(0, 14))
End If
End If