Skip to content
offa edited this page Apr 8, 2015 · 1 revision

A basic example how to use KeyGen code:

const int KEY_LENGTH = 100000; // Key length
UByte* buffer = malloc(KEY_LENGTH * sizeof(UByte)); // allocate buffer

if( buffer == NULL )
{
    // Error - malloc() failed
}
else
{
    KeyGenError err = keygen_createKey(buffer, KEY_LENGTH, ASCII);

    if( err == KG_ERR_SUCCESS )
    {
        // Key generated, do something
    }
    else
    {
        // Error - handle that case
    }

    // Finally clean and free the buffer
    keygen_cleanAndFreeBuffer(buffer, length);
}

Clone this wiki locally