Crypto Plugin

Description

Crypto is an action plugin that expands the available cryptographic actions in AutoPlay Media Studio, Setup Factory, TrueUpdate and Visual Patch. It offers AES (Advanced Encryption Standard), 3DES (Triple Data Encryption Standard) and Twofish encryption algorithms.

Actions

Crypto.AESDecrypt( string Source, string Destination, string Key )

Description:

Creates a decrypted copy of a AES-encrypted file.

Source

(string) The full path to the file that you want to decrypt.

Destination

(string) The full path and filename for the decrypted file.

Key

(string) The secret key to decrypt the data with.

Returns:

Nothing. You can use Application.GetLastError to determine whether this action failed, and why.

Example:

-- Create a AES-encrypted copy of a text file in the user's temp folder
Crypto.AESEncrypt(_TempFolder.."\\myfile.txt", _TempFolder.."\\myfile_aes.txt", "trustno1withthispassword");

-- Check if any errors occurred from calling the Crypto.AESEncrypt action.
-- If an error occurred, display it's error message in a dialog message.
error = Application.GetLastError();
if (error ~=0)then
    Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
end

-- Decrypts the AES-encrypted file.
Crypto.AESDecrypt(_TempFolder.."\\myfile_aes.txt", _TempFolder.."\\myfile_aes_decrypted.txt", "trustno1withthispassword");

-- Check if any errors occurred from calling the Crypto.AESDecrypt action.
-- If an error occurred, display it's  error message in a dialog message.
error = Application.GetLastError();
if (error ~=0) then
    Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
end

-- Open the decrypted file to see its contents.
File.Open(_TempFolder.."\\myfile_aes_decrypted.txt");

Crypto.AESDecryptString( string Text, string Key )

Description:

Decrypts a string that was encrypted using the Crypto.AESEncryptString action. (Decodes a base64-encoded string and decrypts the AES-encrypted data.)

Text

(string) The string that you want to decrypt.

Key

(string) The secret key that the data was encrypted with.

Returns:

(string) The decrypted version of a string that was encrypted with a Crypto.AESEncryptString action. If the key does not match, corrupted data is returned. You can use Application.GetLastError to determine whether this action failed, and why.

Example:

sDecryptedString = Crypto.AESDecryptString(sEncryptedString, sKey);

Crypto.AESEncrypt( string Source, string Destination, string Key )

Description:

Creates a AES-encrypted copy of a file.

Source

(string) The full path to the file that you want to encrypt.

Destination

(string) The full path and filename for the AES-encrypted file.

Key

(string) The secret key to encrypt the data with.

Returns:

Nothing. You can use Application.GetLastError to determine whether this action failed, and why.

Example:

Creates a AES-encrypted copy of a text file in the user's temp folder and then opens that file in the user's default text editor.

-- Create a AES-encrypted copy of a text file in the user's temp folder
Crypto.AESEncrypt(_TempFolder.."\\myfile.txt", _TempFolder.."\\myfile_aes.txt", "trustno1withthispassword");

-- Check if any errors occurred from calling the Crypto.AESEncrypt action.
-- If an error occurred, display it's error message in a dialog message.
error = Application.GetLastError();
if (error ~=0) then
    Dialog.Message("Error", _tblErrorMessages[error] , MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
end

-- Open the encrypted file to see its contents.
File.Open(_TempFolder.."\\myfile_aes.txt");

Crypto.AESEncryptString( string Text, string Key )

Description:

Encrypts a string using AES and returns a base64-encoded string containing the encrypted data.

Text

(string) The string that you want to encrypt.

Key

(string) The secret key to encrypt the data with.

Returns:

(string) A base64-encoded string containing the encrypted data. If the data cannot be encrypted or some other error occurs, an empty string ("") is returned. You can use Application.GetLastError to determine whether this action failed, and why.

Example:

sEncryptedString = Crypto.AESEncryptString(sTextToEncrypt, sSecretKey);

Crypto.RijndaelDecryptString( string Text, table Key, table IV)

Description:

Decrypts a string using the AES algorithm compatible with the .NET Framework implementation.

Text

(string) The string that you want to decrypt.

Key

(table) The secret key to encrypt the data with. This is a table containing 32 bytes (numbers ranging from 0 to 255).

IV

(table) The initialization vector to encrypt the data with. This is a table containing 16 bytes (numbers ranging from 0 to 255).

Returns:

(string) The decoded string. If the data cannot be encrypted or some other error occurs, an empty string ("") is returned. You can use Application.GetLastError to determine whether this action failed, and why.

Example:

-- create a secret key with 32 bytes
key = {};
for i = 1, 32 do
    key[i] = i - 1;
end
-- create an initialization vector with 16 bytes
iv = {};
for i = 1, 16 do
    iv[i] = i - 1;
end
source = "This is a test";
encoded = Crypto.RijndaelEncryptString(source, key, iv);
Debug.Print(encoded .. "\r\n");

decoded = Crypto.RijndaelDecryptString(encoded, key, iv);
Debug.Print(decoded .. "\r\n");

Crypto.RijndaelEncryptString( string Text, table Key, table IV)

Description:

Encrypts a string using the AES algorithm compatible with the .NET Framework implementation. The implementation in this plugin produces the same result as the following .NET code:

RijndaelManaged rman = new RijndaelManaged();
rman.Mode = CipherMode.CBC;
rman.Padding = PaddingMode.PKCS7;
rman.KeySize = 256;

//  Use a 32-byte key (for 256-bit encryption)
byte [] keyBytes = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 };

//  The IV for AES is 16 bytes, because the AES block size is 16.
byte [] ivBytes = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };

ICryptoTransform encryptor = rman.CreateEncryptor(keyBytes, ivBytes);
byte [] plainText = System.Text.Encoding.UTF8.GetBytes("This is a test");
byte [] encrypted = encryptor.TransformFinalBlock(plainText, 0, plainText.Length);

//  Expected output is 31k+86baFy9GJKQ9Y1ebCw==
//  textBox1.Text = Convert.ToBase64String(encrypted);

Text

(string) The string that you want to decrypt.

Key

(table) The secret key to encrypt the data with. This is a table containing 32 bytes (numbers ranging from 0 to 255).

IV

(table) The initialization vector to encrypt the data with. This is a table containing 16 bytes (numbers ranging from 0 to 255).

Returns:

(string) The decoded string. If the data cannot be encrypted or some other error occurs, an empty string ("") is returned. You can use Application.GetLastError to determine whether this action failed, and why.

Example:

-- create the secret key with 32 bytes
key = {};
for i = 1, 32 do
    key[i] = i - 1;
end
-- create the initialization vector with 16 bytes
iv = {};
for i = 1, 16 do
    iv[i] = i - 1;
end
source = "This is a test";
encoded = Crypto.RijndaelEncryptString(source, key, iv);
Debug.Print(encoded .. "\r\n");

decoded = Crypto.RijndaelDecryptString(encoded, key, iv);
Debug.Print(decoded .. "\r\n");

Crypto.TripleDESDecrypt( string Source, string Destination, string Key )

Description:

Creates a decrypted copy of a 3DES-encrypted file.

Source

(string) The full path to the file that you want to decrypt.

Destination

(string) The full path and filename for the decrypted file.

Key

(string) The secret key to decrypt the data with.

Returns:

Nothing. You can use Application.GetLastError to determine whether this action failed, and why.

Example:

-- Create a 3DES-encrypted copy of a text file in the user's temp folder
Crypto.TripleDESEncrypt(_TempFolder.."\\myfile.txt", _TempFolder.."\\myfile_3des.txt", "trustno1withthispassword");

-- Check if any errors occurred from calling the Crypto.TripleDESEncrypt action.
-- If an error occurred, display it's error message in a dialog message.
error = Application.GetLastError();
if (error ~=0)then
    Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
end

-- Decrypts the 3DES-encrypted file.
Crypto.AESDecrypt(_TempFolder.."\\myfile_3des.txt", _TempFolder.."\\myfile_3des_decrypted.txt", "trustno1withthispassword");

-- Check if any errors occurred from calling the Crypto.TripleDESDecrypt action.
-- If an error occurred, display it's  error message in a dialog message.
error = Application.GetLastError();
if (error ~=0) then
    Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
end

-- Open the decrypted file to see its contents.
File.Open(_TempFolder.."\\myfile_3des_decrypted.txt");

Crypto.TripleDESDecryptString( string Text, string Key )

Description:

Decrypts a string that was encrypted using the Crypto.TripleDESEncryptString action. (Decodes a base64-encoded string and decrypts the 3DES-encrypted data.)

Text

(string) The string that you want to decrypt.

Key

(string) The secret key that the data was encrypted with.

Returns:

(string) The decrypted version of a string that was encrypted with a Crypto.TripleDESEncryptString action. If the key does not match, corrupted data is returned. You can use Application.GetLastError to determine whether this action failed, and why.

Example:

sDecryptedString = Crypto.TripleDESDecryptString(sEncryptedString, sKey);

Crypto.TripleDESEncrypt( string Source, string Destination, string Key )

Description:

Creates a 3DES-encrypted copy of a file.

Source

(string) The full path to the file that you want to encrypt.

Destination

(string) The full path and filename for the 3DES-encrypted file.

Key

(string) The secret key to encrypt the data with.

Returns:

Nothing. You can use Application.GetLastError to determine whether this action failed, and why.

Example:

Creates a 3DES-encrypted copy of a text file in the user's temp folder and then opens that file in the user's default text editor.

-- Create a 3DES-encrypted copy of a text file in the user's temp folder
Crypto.TripleDESEncrypt(_TempFolder.."\\myfile.txt", _TempFolder.."\\myfile_3des.txt", "trustno1withthispassword");

-- Check if any errors occurred from calling the Crypto.TripleDESEncrypt action.
-- If an error occurred, display it's error message in a dialog message.
error = Application.GetLastError();
if (error ~=0) then
    Dialog.Message("Error", _tblErrorMessages[error] , MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
end

-- Open the encrypted file to see its contents.
File.Open(_TempFolder.."\\myfile_3des.txt");

Crypto.TripleDESEncryptString( string Text, string Key )

Description:

Encrypts a string using 3DES and returns a base64-encoded string containing the encrypted data.

Text

(string) The string that you want to encrypt.

Key

(string) The secret key to encrypt the data with.

Returns:

(string) A base64-encoded string containing the encrypted data. If the data cannot be encrypted or some other error occurs, an empty string ("") is returned. You can use Application.GetLastError to determine whether this action failed, and why.

Example:

sEncryptedString = Crypto.TripleDESEncryptString(sTextToEncrypt, sSecretKey);

Crypto.TwofishDecrypt( string Source, string Destination, string Key )

Description:

Creates a decrypted copy of a twofish-encrypted file.

Source

(string) The full path to the file that you want to decrypt.

Destination

(string) The full path and filename for the decrypted file.

Key

(string) The secret key to decrypt the data with.

Returns:

Nothing. You can use Application.GetLastError to determine whether this action failed, and why.

Example:

-- Create a twofish-encrypted copy of a text file in the user's temp folder
Crypto.TwofishEncrypt(_TempFolder.."\\myfile.txt", _TempFolder.."\\myfile_twofish.txt", "trustno1withthispassword");

-- Check if any errors occurred from calling the Crypto.TwofishEncrypt action.
-- If an error occurred, display it's error message in a dialog message.
error = Application.GetLastError();
if (error ~=0)then
    Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
end

-- Decrypts the twofish-encrypted file.
Crypto.AESDecrypt(_TempFolder.."\\myfile_twofish.txt", _TempFolder.."\\myfile_twofish_decrypted.txt", "trustno1withthispassword");

-- Check if any errors occurred from calling the Crypto.TwofishDecrypt action.
-- If an error occurred, display it's  error message in a dialog message.
error = Application.GetLastError();
if (error ~=0) then
    Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
end

-- Open the decrypted file to see its contents.
File.Open(_TempFolder.."\\myfile_twofish_decrypted.txt");

Crypto.TwofishDecryptString( string Text, string Key )

Description:

Decrypts a string that was encrypted using the Crypto.TwofishEncryptString action. (Decodes a base64-encoded string and decrypts the twofish-encrypted data.)

Text

(string) The string that you want to decrypt.

Key

(string) The secret key that the data was encrypted with.

Returns:

(string) The decrypted version of a string that was encrypted with a Crypto.TwofishEncryptString action. If the key does not match, corrupted data is returned. You can use Application.GetLastError to determine whether this action failed, and why.

Example:

sDecryptedString = Crypto.TwofishDecryptString(sEncryptedString, sKey);

Crypto.TwofishEncrypt( string Source, string Destination, string Key )

Description:

Creates a twofish-encrypted copy of a file.

Source

(string) The full path to the file that you want to encrypt.

Destination

(string) The full path and filename for the 3DES-encrypted file.

Key

(string) The secret key to encrypt the data with.

Returns:

Nothing. You can use Application.GetLastError to determine whether this action failed, and why.

Example:

Creates a twofish-encrypted copy of a text file in the user's temp folder and then opens that file in the user's default text editor.

-- Create a twofish-encrypted copy of a text file in the user's temp folder
Crypto.TwofishEncrypt(_TempFolder.."\\myfile.txt", _TempFolder.."\\myfile_twofish.txt", "trustno1withthispassword");

-- Check if any errors occurred from calling the Crypto.TwofishDESEncrypt action.
-- If an error occurred, display it's error message in a dialog message.
error = Application.GetLastError();
if (error ~=0) then
    Dialog.Message("Error", _tblErrorMessages[error] , MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
end

-- Open the encrypted file to see its contents.
File.Open(_TempFolder.."\\myfile_twofish.txt");

Crypto.TwofishEncryptString( string Text, string Key )

Description:

Encrypts a string using twofish and returns a base64-encoded string containing the encrypted data.

Text

(string) The string that you want to encrypt.

Key

(string) The secret key to encrypt the data with.

Returns:

(string) A base64-encoded string containing the encrypted data. If the data cannot be encrypted or some other error occurs, an empty string ("") is returned. You can use Application.GetLastError to determine whether this action failed, and why.

Example:

sEncryptedString = Crypto.TwofishEncryptString(sTextToEncrypt, sSecretKey);

 

Error Codes

12040 - Failed to start Crypto Actions plugin.
12041 - Input file not found.
12042 - Could not process input file.
12043 - Could not create output file.

Change Log

2.0.2.0

2.0.1.0

Additional Information

The evaluation build of this plugin uses weak encryption, while the registered version uses strong 256-bit encryption. Strings or files encrypted with the evaluation version cannot be decrypted with the registered version and vice-versa.

Author:

Ulrich Peters
upeters@mindquake.com.br

Copyright:

Plugin is copyright © 2009 MindQuake Serviços de Informática Ltda.

Website:

http://www.mindquake.com.br


Copyright © 2009-2010 MindQuake Serviços de Informática Ltda.
All Rights Reserved.