MFC Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

MFC Examples

Bounced Mail
Bz2
Certificates/Keys
Charset
CSV
Diffie-Hellman
DSA
Email Object
Encryption
FileAccess
FTP
HTML-to-XML
HTTP
IMAP
MHT / HTML Email
MIME
POP3
RSA
SMTP
Socket
Spider
SSH Key
SSH
SSH Tunnel
SFTP
Tar
Upload
XML
Zip


 

 

 

 

 

 

 

 

Using a .NET .snk Key File for RSA Encryption

Demonstrates how to load and use a .NET .snk key file for RSA encryption. SNK files are created by the Microsoft .NET Strong Name Tool (Sn.exe).

Download Chilkat C/C++ Libraries for VC++ 9.0 / Win32

Download Chilkat C/C++ Libraries for VC++ 8.0 / Win32

Download Chilkat C/C++ 64-bit Libraries for VC++ 8.0 / x64

Download Chilkat Visual Studio 2005 C/C++ Libs for Windows Mobile, Pocket PC, SmartPhone, WinCE

Download Chilkat C/C++ Libraries for VC++ 7.0 / Win32

Download Chilkat C/C++ Libraries for VC++ 6.0 / Win32

Download Chilkat C/C++ Libraries for VC++ 6.0, Win 95/98/NT4 Compatible

// Needs #include <CkRsa.h>

    CkString strOut;

    CkRsa rsa;

    bool success;
    success = rsa.UnlockComponent("Anything for 30-day trial");
    if (success != true) {
        strOut.append("RSA component unlock failed\r\n");
        SetDlgItemText(IDC_EDIT1,strOut.getUnicode());
        return;
    }

    //  Load a public/private key pair from a .snk key file.
    const char * xmlKey;
    xmlKey = rsa.snkToXml("chilkat2.snk");

    strOut.append(xmlKey);
    strOut.append("\r\n");

    //  The xmlKey contains both public and private keys.
    //  Import either the public or private for encrypting or
    //  decrypting.
    rsa.ImportPrivateKey(xmlKey);

    bool bUsePrivateKey;
    bUsePrivateKey = true;
    const char * encryptedText;
    encryptedText = rsa.encryptStringENC("Hello World!",bUsePrivateKey);

    strOut.append(encryptedText);
    strOut.append("\r\n");

    //  Now decrypt with the public key:
    rsa.ImportPublicKey(xmlKey);
    bUsePrivateKey = false;
    const char * decryptedText;
    decryptedText = rsa.decryptStringENC(encryptedText,bUsePrivateKey);

    strOut.append(decryptedText);
    strOut.append("\r\n");

    //  Note: We could have just as well encrypted using the public key
    //  and decrypted using the private key.


    SetDlgItemText(IDC_EDIT1,strOut.getUnicode());

Need a specific example? Send a request to support@chilkatsoft.com

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