SOL9 Sample: Random

SOL9 2.0 Samples

1 Screenshot


2 Source code

/*
 * Random.cpp 
 * Copyright (c) 2015 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: 2 May 2016

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