VR-Forces 4.1.1 Class Documentation
Meta Data Script Encrypt/Decrypt

The Meta Data Script Encrypt/Decrypt example demonstrates the following:

The Meta Data Script Encrypt/Decrypt example will show how to set up an encryptor and decryptor routine to encrypt/decrypt language scripts associated with scripted task meta data.

Since this example is loaded as a plugin, it can be used in conjunction with the released VR-Forces application. Make sure to enable the metaDataEncryptDecrypt example from the launcher application.

Usage

Select Settings, Plugins... and on the Plugins Editor page, use the combo box at the top of the page to select the plug-in. Then enable the Load.

To view the new behavior:

  1. New Scenario...
  2. Create a new scenario script.
  3. Edit and save script source with the new scenario script.
  4. Save the scenario.
  5. View the .spt file of the scenario and see that the script is encrypted.

Plugin Entry Points

/*******************************************************************************
** Copyright (c) 2012 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
//\file examplePlugin.cxx
//\brief Loads the plugin that initializes the encrypt/descrypt routine for meta
// data
class DtCgf;
static bool encryptDecryptFunction(const std::string& scriptID, char* input, int inputLen, char** output, int& outputLen, bool encrypt, void* usr)
{
if (encrypt)
{
outputLen = inputLen + 2; // Add 1 for random character and 1 for NULL bit
if (!output)
{
return true;
}
int rand = DtIntRandom(1, 64);
char* outBuf = new char[outputLen];
memset(outBuf, 0, outputLen);
int i;
outBuf[0] = rand;
for (i = 0; i < inputLen; i++)
{
if ((input[i] != '\r') && (input[i] != '\n'))
{
outBuf[i + 1] = input[i] + (rand);
}
else
{
outBuf[i + 1] = input[i];
}
}
*output = outBuf;
return true;
}
else
{
outputLen = inputLen + 1; // Add 1 for NULL bit
int rand = input[0];
char* outBuf = new char[outputLen];
memset(outBuf, 0, outputLen);
int i;
for (i = 0; i < inputLen - 1; i++)
{
if ((input[i + 1] != '\r') && (input[i + 1] != '\n'))
{
outBuf[i] = input[i + 1] - (rand);
}
else
{
outBuf[i] = input[i + 1];
}
}
*output = outBuf;
return true;
}
return false;
}
//Entry point that must be defined by all plugins, this is called as part of the process that loads the plugin, before the de
//is fully initialized
{
DtScriptedTaskMetaData::setEncryptDecryptFunction(&encryptDecryptFunction, false);
return true;
}
extern "C" {
DT_VRF_DLL_PLUGIN bool DtInitializeVrfPlugin(DtCgf* cgf)
{
DtScriptedTaskMetaData::setEncryptDecryptFunction(&encryptDecryptFunction, false);
return true;
}
}
{
info.pluginName = "Scripted Task Meta Data Script Encrypt/Decrypt";
info.pluginDescription = "Encrypt/Decrypt example for encrypting and decrypting scripted tasks scripts";
info.pluginVersion = "1.00";
info.pluginCreator = "MAK Technologies";
info.pluginCreatorEmail = "sales@mak.com";
info.pluginContactWebPage = "www.mak.com";
info.pluginContactMailingAddress = "150 Cambridge Park Drive 3rd Floor - Cambridge, MA 02140 USA";
info.pluginContactPhone = "(617) 876 8085";
}

Document ID: Generated on Mon Apr 8 19:24:01 EDT 2013 from SVN revision 125877
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)