SOL9 2.0 Sample: X509ASNEncDec

SOL9 2.0 Samples

1 Screenshot


2 Source code

/*
 * X509ASNEncDec.cpp 
 * Copyright (c) 2009 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


// SOL9
// 2009/03/17


#include <sol/crypt/X509ASNEncoder.h>
#include <sol/crypt/X509ASNDecoder.h>


void _tmain(int argc, TCHAR** argv)
{
    try {
        X509ASNEncoder encoder;
        X509ASNDecoder decoder;
        { 
            const TCHAR* dn = _T("CN=Arai,O=Antillia,C=COM");
            DWORD stringType = CERT_X500_NAME_STR;
            Bytes name;
            _tprintf(_T("1 Try to encode dn string:%s\n"), dn); 
            if (encoder.toName(
                dn, 
                stringType,
                name) == NO_ERROR) {
                //
                _tprintf(_T("2 OK, encoder.toName()\n"));
                name.dump();


                String string;
                _tprintf(_T("3 Try to decode \n")); 

                if (decoder.toString(
                    name,
                    stringType,
                    string)  == NO_ERROR) {
                    _tprintf(_T("4 OK, decoder.toString() string:%s \n"), 
                        (const TCHAR*)string);
                } else {
                    _tprintf(_T("5 Failed decoder.toString()\n"));
                }
            } else {
                _tprintf(_T("6 Failed encoder.toName()\n"));
            }
        }    

    } catch (...) {
        printf("Exception: %x\n", GetLastError());

    }

}

Last modified: 11 Nov 2009

Copyright (c) 2009 Antillia.com ALL RIGHTS RESERVED.