3DES Encryption
3DES Encryption
bool success;
success = crypt.UnlockComponent("Anything for 30-day trial");
if (success != true) {
// Unlock failed.
MessageBox.Show(crypt.LastErrorText);
return;
}
// (it is also possible to set the key directly from a byte array, or generate
// a key from a arbitrary-length string password.)
// Note: If trying to match the results produced by two different 3DES implementations,
// make sure to test with data that is longer than a single block (8 bytes for 3DES).
// If all params match (IV, secret key, cipher mode, etc.) except for the padding, then
// the results will be identical except for the last block of output. If you test data is only
// a single block, you cannot recognize the situation where all is correct except
// for a padding mismatch.
string cipherText;
string plainText;
cipherText = crypt.EncryptStringENC("ABCDEFGHIJKLMNLPQRSTUVWXYZ");
textBox1.Text += cipherText + "\r\n";
plainText = crypt.DecryptStringENC(cipherText);
textBox1.Text += plainText + "\r\n";
// Note: Because we used SPACE character padding, the output string will contain trailing SPACE
// chars, which can easily be trimmed.
// (Other padding schemes embed the original input length in the padding so that the Decrypt*
methods always
// return the exact original data).