VR-Forces 5.0.2 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Meta Data Script Encrypt/Decrypt (metaDataEncryptDecrypt)

Table of Contents

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

Setting an encryptor and decryptor

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.

How to Run the Example

Usage

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

To view the new behavior:

  1. Start VR-Forces GUI and SIM.
  2. Create a new scneario - e.g. EntityLevel SMS on Ground_DB II terrain.
  3. Create a new scenario script.
  4. Edit and save script source code from the new scenario script.
  5. Save the scenario.
  6. Unzip the scenario file.
  7. View the .spt file of the scenario and see that the script source code 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
{
return true;
}
extern "C" {
DT_VRF_DLL_PLUGIN bool DtInitializeVrfPlugin(DtCgf* cgf)
{
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 = "10 Fawcett Street, Suite 204, Cambridge, MA 02138 USA";
info.pluginContactPhone = "(617) 876 8085";
}

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)