Visual Basic Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

VB Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
RSA
S/MIME
SFTP
SMTP
Socket
Spider
SSH
SSH Key
SSH Tunnel
String
Tar
Upload
XML
XMP
Zip Compression

More Examples...
Amazon S3
Email Object
DKIM / DomainKey
NTLM
DH Key Exchange
DSA
FileAccess
RSS
Atom
Self-Extractor
Service
Bzip2
PPMD
Deflate
LZW


VB Strings
VB Byte Array

 

 

 

 

 

 

 

Generate RSA Public/Private Key Pair and Export to PEM

Visual Basic example code showing how to generate an RSA public/private key pair and export to PEM files.

Download 32-bit Chilkat RSA ActiveX (.msi)

Download All 32-bit Chilkat ActiveX Components (.zip)

Download All 64-bit Chilkat ActiveX Components (.zip)

Dim rsa As New ChilkatRsa

Dim success As Long
success = rsa.UnlockComponent("Anything for 30-day trial")
If (success <> 1) Then
    MsgBox "RSA component unlock failed"
    Exit Sub
End If

'  Generate a 1024-bit key.  Chilkat RSA supports
'  key sizes ranging from 512 bits to 4096 bits.
success = rsa.GenerateKey(1024)
If (success <> 1) Then
    MsgBox rsa.LastErrorText
    Exit Sub
End If

'  Keys are exported in XML format:
Dim publicKeyXml As String
publicKeyXml = rsa.ExportPublicKey()
Text1.Text = Text1.Text & publicKeyXml & vbCrLf

Dim privateKeyXml As String
privateKeyXml = rsa.ExportPrivateKey()
Text1.Text = Text1.Text & privateKeyXml & vbCrLf

'  Save the private key in PEM format:
Dim privKey As New PrivateKey
privKey.LoadXml privateKeyXml
privKey.SaveRsaPemFile "privateKey.pem"

'  Save the public key in PEM format:
Dim pubKey As New PublicKey
pubKey.LoadXml publicKeyXml
pubKey.SaveOpenSslPemFile "publicKey.pem"

© 2000-2012 Chilkat Software, Inc. All Rights Reserved.