Online Help
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.
Creates a decrypted copy of a AES-encrypted file.
(string) The full path to the file that you want to decrypt.
(string) The full path and filename for the decrypted file.
(string) The secret key to decrypt the data with.
Nothing. You can use Application.GetLastError to determine whether this action failed, and why.
-- 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");
Decrypts a string that was encrypted using the Crypto.AESEncryptString action. (Decodes a base64-encoded string and decrypts the AES-encrypted data.)
(string) The string that you want to decrypt.
(string) The secret key that the data was encrypted with.
(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.
sDecryptedString = Crypto.AESDecryptString(sEncryptedString, sKey);
Creates a AES-encrypted copy of a file.
(string) The full path to the file that you want to encrypt.
(string) The full path and filename for the AES-encrypted file.
(string) The secret key to encrypt the data with.
Nothing. You can use Application.GetLastError to determine whether this action failed, and why.
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");
Encrypts a string using AES and returns a base64-encoded string containing the encrypted data.
(string) The string that you want to encrypt.
(string) The secret key to encrypt the data with.
(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.
sEncryptedString = Crypto.AESEncryptString(sTextToEncrypt, sSecretKey);
Encrypts a string using the 256 bit AES algorithm compatible with the PHP implementation.
(string) The string that you want to encrypt.
(string) A string that is 32 characters long, representing the hexadecimal number to the used as the key for 256-bit encryption.
(string) A string that is 16 characters long, representing the hexadecimal number to be used as the initialization vector.
(string) The encoded 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.
source = "The quick brown fox jumped over the lazy dog"; key = "1A3B56C89D123E6123F456A890B2345F"; iv = "C234A67D901B34F6"; encoded = Crypto.MCryptString(source, key, iv); Debug.Print(encoded .. "\r\n"); -> 2fddc3abec692e1572d9b7d629172a05caf230bc7c8fd2d26ccfd65f9c54526984f7cb1c4326ef058cd7bee3967299e3
$cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
$key256 = '1A3B56C89D123E6123F456A890B2345F'; // 32 bytes
$iv = 'C234A67D901B34F6'; // 16 bytes
$cleartext = 'The quick brown fox jumped over the lazy dog';
if (mcrypt_generic_init($cipher, $key256, $iv) != -1) {
$cipherText = mcrypt_generic($cipher, $cleartext );
mcrypt_generic_deinit($cipher);
// Display the result (in hexadecimal)
printf("256-bit encrypted result:\n%s\n\n", bin2hex($cipherText));
}
Decrypts a string using the 256 bit AES algorithm compatible with the PHP implementation.
(string) The string that you want to decrypt.
(string) A string that is 32 characters long, representing the hexadecimal number to the used as the key for 256-bit encryption.
(string) A string that is 16 characters long, representing the hexadecimal number to be used as the initialization vector.
(string) The decoded string. If the data cannot be decrypted or some other error occurs, an empty string ("") is returned. You can use Application.GetLastError to determine whether this action failed, and why.
source = "2fddc3abec692e1572d9b7d629172a05caf230bc7c8fd2d26ccfd65f9c54526984f7cb1c4326ef058cd7bee3967299e3"; key = "1A3B56C89D123E6123F456A890B2345F"; iv = "C234A67D901B34F6"; decoded = Crypto.MDecryptString(encoded, key, iv); Debug.Print(decoded .. "\r\n"); -> The quick brown fox jumped over the lazy dog
$cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
$key256 = '1A3B56C89D123E6123F456A890B2345F'; // 32 bytes
$iv = 'C234A67D901B34F6'; // 16 bytes
$outText = '2fddc3abec692e1572d9b7d629172a05caf230bc7c8fd2d26ccfd65f9c54526984f7cb1c4326ef058cd7bee3967299e3';
if (mcrypt_generic_init($cipher, $key256, $iv) != -1) {
$cipherText = pack("H*", $outtext);
$newtext = mdecrypt_generic($cipher, $cipherText);
mcrypt_generic_deinit($cipher);
// Display the result (in cleartext)
printf("Decrypted:\n%s\n", $newtext);
}
Decrypts a string using the AES algorithm compatible with the .NET Framework implementation.
(string) The string that you want to decrypt.
(table) The secret key to encrypt the data with. This is a table containing 32 bytes (numbers ranging from 0 to 255).
(table) The initialization vector to encrypt the data with. This is a table containing 16 bytes (numbers ranging from 0 to 255).
(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.
-- 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");
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);
(string) The string that you want to decrypt.
(table) The secret key to encrypt the data with. This is a table containing 32 bytes (numbers ranging from 0 to 255).
(table) The initialization vector to encrypt the data with. This is a table containing 16 bytes (numbers ranging from 0 to 255).
(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.
-- 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");
Creates a decrypted copy of a 3DES-encrypted file.
(string) The full path to the file that you want to decrypt.
(string) The full path and filename for the decrypted file.
(string) The secret key to decrypt the data with.
Nothing. You can use Application.GetLastError to determine whether this action failed, and why.
-- 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");
Decrypts a string that was encrypted using the Crypto.TripleDESEncryptString action. (Decodes a base64-encoded string and decrypts the 3DES-encrypted data.)
(string) The string that you want to decrypt.
(string) The secret key that the data was encrypted with.
(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.
sDecryptedString = Crypto.TripleDESDecryptString(sEncryptedString, sKey);
Creates a 3DES-encrypted copy of a file.
(string) The full path to the file that you want to encrypt.
(string) The full path and filename for the 3DES-encrypted file.
(string) The secret key to encrypt the data with.
Nothing. You can use Application.GetLastError to determine whether this action failed, and why.
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");
Encrypts a string using 3DES and returns a base64-encoded string containing the encrypted data.
(string) The string that you want to encrypt.
(string) The secret key to encrypt the data with.
(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.
sEncryptedString = Crypto.TripleDESEncryptString(sTextToEncrypt, sSecretKey);
Creates a decrypted copy of a twofish-encrypted file.
(string) The full path to the file that you want to decrypt.
(string) The full path and filename for the decrypted file.
(string) The secret key to decrypt the data with.
Nothing. You can use Application.GetLastError to determine whether this action failed, and why.
-- 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");
Decrypts a string that was encrypted using the Crypto.TwofishEncryptString action. (Decodes a base64-encoded string and decrypts the twofish-encrypted data.)
(string) The string that you want to decrypt.
(string) The secret key that the data was encrypted with.
(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.
sDecryptedString = Crypto.TwofishDecryptString(sEncryptedString, sKey);
Creates a twofish-encrypted copy of a file.
(string) The full path to the file that you want to encrypt.
(string) The full path and filename for the 3DES-encrypted file.
(string) The secret key to encrypt the data with.
Nothing. You can use Application.GetLastError to determine whether this action failed, and why.
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");
Encrypts a string using twofish and returns a base64-encoded string containing the encrypted data.
(string) The string that you want to encrypt.
(string) The secret key to encrypt the data with.
(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.
sEncryptedString = Crypto.TwofishEncryptString(sTextToEncrypt, sSecretKey);
Retrieves the current hardware ID for the current machine. This function should be used to retrieve the hardware ID in a machine to link serial numbers to a specific machine.
(string) The hardware id, in the format XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX, where 'X' can be any hexadecimal character (0-9, A-F). If an error occurs, an empty string ("") is returned. You can use Application.GetLastError to determine whether this action failed, and why.
-- set a session variable with the hardware fingerprint for further use
SessionVar.Set("%HardwareID%", Crypto.GetHardwareID());
12040 - Library error.
12041 - Input file not found.
12042 - Could not process input file.
12043 - Could not create output file.
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.
Ulrich Peters
upeters@mindquake.com.br
Plugin is copyright © 2009 MindQuake Serviços de Informática Ltda.
Copyright © 2009-2010 MindQuake Serviços de Informática Ltda.
All Rights Reserved.