Sample code for 30+ languages & platforms
Visual FoxPro

RSA Import Public Key from Certificate PEM

See more RSA Examples

Uses a certificate's public key for RSA encryption. The public key from the certificate .pem file is used.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loCert
LOCAL loPubKey
LOCAL loRsa
LOCAL lcEncryptedStr

lnSuccess = 0

loCert = CreateObject('Chilkat.Cert')

lnSuccess = loCert.LoadFromFile("qa_data/pem/mf_public_rsa.pem")
IF (lnSuccess = 0) THEN
    ? loCert.LastErrorText
    RELEASE loCert
    CANCEL
ENDIF

loPubKey = CreateObject('Chilkat.PublicKey')
loCert.GetPublicKey(loPubKey)

loRsa = CreateObject('Chilkat.Rsa')
loRsa.UsePublicKey(loPubKey)

loRsa.EncodingMode = "base64"
lcEncryptedStr = loRsa.EncryptStringENC("hello",0)
? "encrypted string = " + lcEncryptedStr

RELEASE loCert
RELEASE loPubKey
RELEASE loRsa