SOL9 2.0 Sample: Random

SOL9 2.0 Samples

1 Screenshot


2 Source code

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


//2009/02/17

#include <sol/crypt/CryptServiceProvider.h>
#include <sol/Bytes.h>
#include <sol/crypt/Random.h>


int _tmain(int argc, TCHAR** argv)
{
    int rc = 0;

    try {

        CryptServiceProvider csp;

        Random random;
        const int SIZE = 64;
        unsigned char buffer[SIZE];
    
        unsigned int length = SIZE;
        memset(buffer, 0, SIZE);
        random.generate(csp, buffer, length);
        Bytes bytes;
        bytes.set(buffer, length);
        bytes.dump();


    } catch (Exception& ex) {
        printf("Exception = %s\n", ex.getErrorMessage());
    }

    rc = GetLastError();

    return rc;
}

Last modified: 11 Nov 2009

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