Using Code of CTI 1.1

This software is written in C#.

1. Start a new project in Visual Studio.
2. Add a reference of .NET component System.Management.
3. Create a textbox, which design name is textbox1.
3. Download the Source Code of this project.
4. Extract it. Locate a file Encrypt.cs in the Encrypt folder and add it to your current cs project.
5. Add a using command line (shown below) at the top of your cs project file.

 

using System.Management; 

 

Now, we can play with the encryption.

Examples

Example 1: Simple single string encryption with default settings

string password = "abc123"; 
this.textBox1.Text = CTI1.Encrypt(password);

Result:
TBozBDnjj37c4UH9b7wi8d3Y8411nb

Example 2: Simple single string encryption with output length of 45

string password = "abc123";
this.textBox1.Text = CTI1.Encrypt(password, 45);

Result:
hHe0Hc7q6SJAozPM1Jqm57epF5vo3HS505M6FFh801J8P

Example 3: Separate encrypted code into 5 blocks. Each block length is 5.

int[] blockSize = new int[] {5,5,5,5,5};
string password = "abc123";
this.textBox1.Text = CTI1.Encrypt(password, blockSize);

Result:

0Y9YH-MkiTF-FLgDZ-53ex3-29JSG

Example 4: Encrypt with 3 keys, Processor ID and Hard Disk serial number. Then, separate the blocks with this separator "/".

CTI1.EncryptWithProcessorID = true;
CTI1.EncryptWithHardDiskSerial = true;
CTI1.Separator = "/";

string password = "abc123";

string key1_bossName = "Michell Anderson";
string key2_mySecretKey = "12345678";
string key3_mySecretKey = "raining cats and dogs";

List<string> multipleKey = new List<string>();

multipleKey.Add(key1_bossName);
multipleKey.Add(key2_mySecretKey);
multipleKey.Add(key3_mySecretKey);

int[] blockSize = new int[] { 5, 5, 5, 5, 5 };

this.textBox1.Text = CTI1.EncryptEncrypt(password, multipleKey, blockSize);

Result:
1h8T7/5idBP/nD8IE/e2lIO/gdg7C

Example 5: Set the output format as Numbers only.

CTI1.OutputFormat = Encrypt.Encrypt.OutputCharFormat.NumberOnly;
string email = "abc123@abc123.com";
this.textBox1.Text = CTI1.Encrypt(email);

Result:

494253140331165696353975755262

Available output format:

  • All,
  • TextOnly,
  • NumberOnly,
  • SymbolOnly,
  • TextSymbol,
  • NumberSymbol,
  • TextNumber,
  • UpperCaseText,
  • UpperCaseTextNumber,
  • LowerCaseText,
  • LowerCaseTextNumber

Example 6: Display the Processor ID and Hard Disk Serial Number

MessageBox.Show(CTI1.FindProcessorId());
MessageBox.Show(CTI1.FindHardDiskId());


Example 7: Enable type-safe. Exclude the character of "I", "i", "l", "1", "0", "O", "o" from the output.

CTI1.OutputFormat = Encrypt.Encrypt.OutputCharFormat.TextNumber;
CTI1.EnableTypeSafe = true;
string email = "abc123@abc123.com";
this.textBox1.Text = CTI1.Encrypt(email);

Result:
23sS3K76Ng2W3aDKQ5TNZe27hqgkH7

Note: type-safe will be deactivate, if the output format is set to NumberOnly.


Example of Application

Example 1: Password Authentication

 

string password_encrypted = "D6d3d1BbnT4M9n81j787j4N8BYcbo3";
string password_keyin = "123456";

if(CTI1.Encrypt(password_keyin) == password_encrypted)
{
      MessageBox.Show("Password Correct. Login Successful");
}
else
{
      MessageBox.Show("Password Incorrect. Login Fail");
}

Example 2: Product Activation

CTI1.EncryptWithHardDiskSerial = true;
CTI1.EncryptWithProcessorID = true;
CTI1.EnableTypeSafe = true;
CTI1.OutputFormat = Encrypt.Encrypt.OutputCharFormat.UpperCaseTextNumber;
string UserEmail = "john@abc123.com";

// User obtain their computer's Hardware ID
string HardwareID = CTI1.Encrypt(UserEmail, 8);

// Hardware ID generated, which is "2Z7CJ5U8"

// User submit their email and hardware id for buying a software product activation key

string UserEmail = "john@abc123.com";
string HardwareID = "2Z7CJ5U8";

// Software Owner generate Product Activation Code

int[] ActivationCodeBlockSize = new int[] { 8, 4 };
string ProductActivationCode = CTI1.Encrypt(UserEmail, HardwareID, ActivationCodeBlockSize);

// Product Activation Code generated = 535R84MC-7877

// User received the Product Code and Activate the software in their computer

// Product Activation
CTI1.EncryptWithHardDiskSerial = false;
CTI1.EncryptWithProcessorID = false;

string userKeyInCode = "535R84MC-7877";
if (userKeyInCode == CTI1.Encrypt(UserEmail, HardwareID, ActivationCodeBlockSize)
{
      MessageBox.Show("Activation Code correct. Product activated successfully");
}
else
{
      MessageBox.Show("Invalid Activation Code. Product fail to activate");
}

Last edited Sep 28, 2011 at 6:10 AM by adriancs, version 5

Comments

No comments yet.