Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

DataFlex Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(DataFlex) Load SSH Keys Produced by ssh-keygen

Demonstrates how to load the public and private keys produced by ssh-keygen.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoPubkey
    Boolean iSuccess
    Handle hoPrivkey
    String sTemp1

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    // We first generate a key like this:

    //     ssh-keygen -f stg.chilkat.id
    //     Generating public/private rsa key pair.
    //     Enter passphrase (empty for no passphrase):
    //     Enter same passphrase again:
    //     Your identification has been saved in stg.chilkat.id.
    //     Your public key has been saved in stg.chilkat.id.pub.
    //     The key fingerprint is:
    //     SHA256:hkbgexkspxYTa8rYUxouRU8Gi7lbbsT6dSLX+JlStKk me@example02240
    //     The key's randomart image is:
    //     +---[RSA 2048]----+
    //     |  o.=            |
    //     | + * =           |
    //     |o + X =          |
    //     | O * O.+         |
    //     |+ @ +.=oS        |
    //     | A o =+.         |
    //     |o + =oo          |
    //     | o +E+ o         |
    //     |  .  .+          |
    //     +----[SHA256]-----+

    // 

    // The public key (generated to the file stg.chilkat.id.pub) contains this:
    // ssh-rsa AAAAB3NzaC1yc2EAAAADAQABA.. FDt+dKJEkhw8I7LpEi17diB9 me@example02240

    // First let's load the public key:
    Get Create (RefClass(cComChilkatSshKey)) To hoPubkey
    If (Not(IsComObjectCreated(hoPubkey))) Begin
        Send CreateComObject of hoPubkey
    End

    Get ComLoadText Of hoPubkey "qa_data/sshKeys/ssh-keygen/stg.chilkat.id.pub" To sTemp1
    Get ComFromOpenSshPublicKey Of hoPubkey sTemp1 To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoPubkey To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComLastErrorText Of hoPubkey To sTemp1
    Showln sTemp1
    Showln "Successfully loaded the public key."

    // Now try the private key, which contains this:

    // -----BEGIN OPENSSH PRIVATE KEY-----
    // b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABFwAAAAdzc2gtcn
    // NhAAAAAwEAAQAAAQEArNH9CpKhVgpGbOEDaFH4CaL9iQE6IwVYqKFkcF9qdHc6XA+J9PeR
    // 9CMvTtVWm/uCYsoYzRkitNIEokjxFwyQwJeng+qWh5t538Ji3v64ls0mgsdvecyYDYjU8T
    // mqhivXk/DzNBUOuyN5ksP0ZmRJLuZ4J6MKCrPugvKsE4zDQkg7/lKUL40ugjpoYJnhRjHv
    // uogSkcecq6Kdw20WdRWTFvXiRH8mdh9cVWi3fvj0sly0CDghmuWyjvcrIOuixvy8kfADva
    // tDAyF1se0r8WW9xZzUYHjuCzxbI+yfU3xS9/vX9T9IG10ocSbqrBgd/xQ7fnSiRJIcPCOy
    // 6RIte3YgfQAAA9BXf/XaV3/12gAAAAdzc2gtcnNhAAABAQCs0f0KkqFWCkZs4QNoUfgJov
    // 2JATojBViooWRwX2p0dzpcD4n095H0Iy9O1Vab+4JiyhjNGSK00gSiSPEXDJDAl6eD6paH
    // m3nfwmLe/riWzSaCx295zJgNiNTxOaqGK9eT8PM0FQ67I3mSw/RmZEku5ngnowoKs+6C8q
    // wTjMNCSDv+UpQvjS6COmhgmeFGMe+6iBKRx5yrop3DbRZ1FZMW9eJEfyZ2H1xVaLd++PSy
    // XLQIOCGa5bKO9ysg66LG/LyR8AO9q0MDIXWx7SvxZb3FnNRgeO4LPFsj7J9TfFL3+9f1P0
    // gbXShxJuqsGB3/FDt+dKJEkhw8I7LpEi17diB9AAAAAwEAAQAAAQAPUtNAA75gdarG7rCx
    // qEr498XJRx2Ti17QHPdd62fyCbxX+1y9JtJ/Njt0nv/99rAZ+Fd4oBjutYyJozQVWhzfpt
    // LIpJ1SStvklkTUBvvxCyG2CN7+isCUuqQ++2D+YpbL3FqELLXQrBWUiOF7zrqaeP8AbLlw
    // N4IXhFLzrNCHaODsbYAh8U1nOj1PvUO24quCzPRPH/LcERvgXeGEJSYoB0nwwKGppIpBnv
    // jV5wvuhPdQVvN14e8SOodK76InfaGUsCUwr2ksaGhsTCGk7yCsyQUyzzV8InQ3CTPkLf9J
    // BnBpymoyB/r3LnefX4AgKA7nplCRUANLbvTACTazHtcBAAAAgQCihdCPzywEkrn0VhYIOV
    // sK7oIUD/EBEzb7yL+7naZqACStbhKiLKGgSJj2+3hgmQk2tZ94zN5lkCcLLFy9Ai47HkN+
    // dSmZqac5pQeVyWrJ/67OSqWxMFfjkbF/0IxXJM2y+i//vGWBDo3NJmkYGwY+XnFP81qqh9
    // boeQA0K6wn0wAAAIEA2tX2lZrwAyhl/L5XY1xsQ3uuoaIUeZD0vUs+mAv1pz8fbTAD2n37
    // Rh57mxDNQIwiD8lV5wZ20NP03nAr8gUQaijsBRy3gDXHX7Qa/BaJ2bY0492HXwVYi9bsng
    // GJQinYjmJQQeR/w4u5rNzuD8y1ysMwh/sE8IGu6LLG1IBDYr0AAACBAMord/G9vderFO+1
    // tNZHl09m9mFLJTHRVH41Da2uCl2KJnYir511M9GSG9Un6L+UGu4F9CrypehgJHZ6QbwpgS
    // JrwlCfE09jPkuH0aktg9fnrrEJYS30wWNNSj1v/91v1F3fdrZePd+UnKcP6zZB3jICzPhW
    // elU1OYdWf+qFrnDBAAAAGWRqYWNrc29uMDIyQGRqYWNrc29uMDIyNDAB
    // -----END OPENSSH PRIVATE KEY-----

    Get Create (RefClass(cComChilkatSshKey)) To hoPrivkey
    If (Not(IsComObjectCreated(hoPrivkey))) Begin
        Send CreateComObject of hoPrivkey
    End

    Get ComLoadText Of hoPubkey "qa_data/sshKeys/ssh-keygen/stg.chilkat.id" To sTemp1
    Get ComFromOpenSshPrivateKey Of hoPrivkey sTemp1 To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoPrivkey To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComLastErrorText Of hoPrivkey To sTemp1
    Showln sTemp1
    Showln "Successfully loaded the private key."


End_Procedure

 

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