Introduction
Connecting to cell phone in an easy way and getting its information is very important for some applications such as SMS Senders and Bluetooth connections and this tip shows how to connect to cell phones that are connected to the computer by Bluetooth or USB cable that have one Com Port and request AT Command from mobile set.
Background
Decrypting and encrypting files and data is a very sophisticated subject but I am using that in this tip just for the main subject.
This project scenario steps are as follows:
- Connect cell phone by Bluetooth or other connectivity tools to computer
- Select source file and mobile Com port and select output file path
- Create target file and get length of source file in byte count
- Connect to mobile phone and read its Serial Number
- Decrypt/Encrypt source file to target file by XOR Style that XOR all source file bytes by XOR to Key value that in this project is Mobile Phone Serial Number
Text and binary files format and its standards vary, for example character standards (ASCII, Unicode v1,2,3,4 and other), video and image files header and data.
For this reason, read and write files must be done in a basic way. Read and write byte to byte (8 bit) from source to target.
Using the Code
Reading Com Ports
From static method in SerialPort class loads all Com (Serial) Ports to Port Combo:
private void btnRefreshports_Click(object sender, EventArgs e)
{
cmbPort.Items.Clear();
string[] lPorts = SerialPort.GetPortNames();
foreach (string str in lPorts)
{
cmbPort.Items.Add(str);
}
if (cmbPort.Items.Count > 0)
cmbPort.SelectedIndex = 0;
}
Read more: Codeproject
QR: