The Meta Data Script Encrypt/Decrypt example demonstrates the following:
- How to add a meta data encrypt and decrypt method to the front-end and back-end.
- How to write a front-end example that works in conjuction with a back-end example.
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:
-
New Scenario...
-
Create a new scenario script.
-
Edit and save script source with the new scenario script.
-
Save the scenario.
-
View the .spt file of the scenario and see that the script is encrypted.
Plugin Entry Points
static bool encryptDecryptFunction(const std::string& scriptID, char* input, int inputLen, char** output, int& outputLen, bool encrypt, void* usr)
{
if (encrypt)
{
outputLen = inputLen + 2;
if (!output)
{
return true;
}
char* outBuf = new char[outputLen];
memset(outBuf, 0, outputLen);
int i;
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;
unsigned int rand = input[0];
if (rand < 128)
{
return false;
}
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;
}
{
return true;
}
extern "C" {
{
return true;
}
}
{
info.
pluginName =
"Scripted Task Meta Data Script Encrypt/Decrypt";
info.
pluginDescription =
"Encrypt/Decrypt example for encrypting and decrypting scripted tasks scripts";
}