VR-Forces 4.5 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Meta Data Script Encrypt/Decrypt (metaDataEncryptDecrypt)

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

In the Launcher, click the Plug-ins button to bring up the Plug-ins Selection dialog. Enable the plugin. Then launch VR-Forces.

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;
// Put char at > normal ASCII value to indicate that if this value is not read in as such on decrypt
// it is an unencrypted file
outBuf[0] = 128 + 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
unsigned int rand = input[0];
if (rand < 128)
{
return false; // Nothing to decrypt
}
rand -= 128;
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 Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)