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
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:
-
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] = 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;
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;
}
{
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";
}