(Visual FoxPro) Generate RSA Public/Private Key
Visual FoxPro example code showing how to generate an RSA public/private key.
LOCAL loRsa
LOCAL lnSuccess
LOCAL lcPublicKey
LOCAL lcPrivateKey
* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Rsa')
loRsa = CreateObject('Chilkat.Rsa')
* Generate a 1024-bit key. Chilkat RSA supports
* key sizes ranging from 512 bits to 4096 bits.
* Note: Starting in Chilkat v9.5.0.49, RSA key sizes can be up to 8192 bits.
* It takes a considerable amount of time and processing power to generate
* an 8192-bit key.
lnSuccess = loRsa.GenerateKey(1024)
IF (lnSuccess <> 1) THEN
? loRsa.LastErrorText
RELEASE loRsa
CANCEL
ENDIF
* Keys are exported in XML format:
lcPublicKey = loRsa.ExportPublicKey()
? lcPublicKey
lcPrivateKey = loRsa.ExportPrivateKey()
? lcPrivateKey
RELEASE loRsa
|