Professional Documents
Culture Documents
Step 4: Take pc0, pc1 for switch0, take pc2, pc3 for switch1.
Step 5: Connect pc0, pc1 to Switch0 with Straight through cable, connect pc2,
pc3 to Switch1 with straight through cable, and connect Switch0 to Hub0 with
cross over cable, connect Switch1 to Hub1 with cross over cable. Connect
Hub0, Hub1 to Router0 with straight through cable.
Go to Router0 → CLI
Router>enable
Router#configure terminal
Router(config)#interface fastEthernet 0/0
Router(config-if)#ip address 10.10.1.1 255.0.0.0
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#interface fastEthernet 0/0
Router(config-if)#ip address 192.168.1.1 255.255.255.0
Router(config-if)#no shutdown
1.
2. Make sure your PC is plugged in. Connect a telephone cord from the back of your
PC to the Telephone jack outlet located on the wall of the room you are in. Turn your PC
power on.
3.Go to the control panel. When your PC is finished starting up, you should be on your
main desktop page. You should also see various icons. Look for the icon that is named
"my computer". Enter my computer. When you enter you should see a small square panel
to left of your screen that says "other places". In that panel are 4 items you can click on.
Click on the one that says "control panel".
4. Go to network connections. In the control panel you will see various icons. The
control panel lets you change the settings of your computer such as; adding new
software to your computer, changing your mouse icon, adding a new user to the
computer, or in this case creating/editing your internet account. While in the
control panel, look for the icon that says "network connections". Double click the
icon to enter it.
5. Create a new connection. On this screen you will see basically nothing. Look
to the upper left hand side of your screen, you should see a small square panel
that says "network tasks". In this panel there is a small icon with the words
"create a new connection". Enter this icon.
6.A small window will pop up, just click the next button once.
7.There are 4 bulletins to choose from. Since this is a dial-up connection that is being
set up. Click on the one that says "connect to the internet". Then click the next button.
8.There are now 3 bulletins you can click on, click the one that says "set up my
connection manually". Click the next button.
9.. Another set of 3 bulletins will appear, click on "connect using a dial up
modem". Then click the next button.
10 You will now be asked to type in your internet’s ISP name. You may
name this whatever you want to name it. (Ex, Your name, last name,
nickname) Type in your ISP name then click the next button.
11.Now you will be asked to type in a phone number (The number you type in will
be the number that you got from customer care while you were setting up your
account in step 1) Type in the phone number and click the next button.
12.Now you will see 3 boxes, one asks for your user name. The other two are for your
password. Type in your user name. (You got your user name while you were on the
phone with your internet service provider in step 1) Do the same process for the
password. Once you have filled in the 3 boxes click the next button.
13
PRAC 9. Write the steps in providing network security and to set
firewall security in windows.
A. SETUP SYSTEM AND SECURITY SETTINGS.1. Set up
system and security settings
1. From the Start menu, click Control Panel, then click System and
Security
2. Under Windows Firewall, select either Check firewall status to determine
whether the firewall is turned on or off, or Allow a program through
Windows Firewall to allow a blocked program through the firewall
3. B.B
BBBBBBBBB
BBogram features
B. SELECT PROGRAM FEATURES.
1. Click Turn Windows Firewall on or off from the left side menu
2. Configure the settings for your home/work (private) or public network
3. Click OK to save your changes
1. Turn on Windows Firewall for each network location you use - Home or
work (private) or Public
o Click What are network locations? for more information on
network types
o Domain network locations are controlled by your network
administrator and can't be selected or changed
2. Select Turn on Windows Firewall under the applicable network location
type (in image below, both locations are selected)
3. Select Notify me when Windows Firewall blocks a new program for
each network type, if the box is not already checked
4. Click OK to save your changes.
PRAC 10. WRITE THE STEPS FOR INSTALLATION OF System
Software, Application Software and Antivirus.
Applications like Microsoft Office and Adobe Photoshop can now be purchased
and downloaded right to your computer. You can also install free software this
way.
Installing Windows 10
1
Create Windows Installation media. If you order Windows 10 for a new PC build, they
may send you an installation media. If you don't have a Windows installation media, you
can make one. You'll need a computer with internet access and an 8 GB USB flash drive
(16 GB recommended). You also need to know if the computer you want to install
Windows 10 on has 32-bit or 64-bit architecture. You will also need to purchase
Windows to get a product key. This can be done before or after the installation. Use the
following steps to create a Windows Installation Media:
Insert a USB drive with at least 8 GB of space into any computer with internet
access. This will wipe any existing data on the USB drive, so be sure to back
up any data you want to keep.
Go to https://www.microsoft.com/en-us/software-download/windows10 in a
web browser.
Click Download Tool Now.
Open the "MediaCreationTool.exe" file in your web browser or Downloads
folder.
Click Accept.
Select "Create Installation Media (USB drive, DVD, ISO file) for another PC"
and click Next.
Select your language, Windows edition, and PC architecture and click Next.
Select "USB flash drive" and click Next.
Select your USB drive and click Next.
2
Back up your files (optional). If you already have a Windows installation on your
computer, a new Windows installation may overwrite your files. Back up any data you
want to keep before beginning a new Windows installation. You can back up your files to
OneDrive, Google Drive, Dropbox, or an external hard drive or USB flash drive.
3
Insert the Windows Installation Media in the computer you want to install Windows
on. You can insert the Windows Installation media into any free USB port.
4
Boot the computer. If the PC is already powered on, restart it using the normal restart
procedures of the operating system that is installed on the PC. If it is not yet powered on,
press the power button to boot it up.
5
Enter the Boot menu. Most newer computers have a boot menu you can enter while
booting up. The way you enter it is different, depending on your motherboard. The most
common way to enter the Boot menu is to press F10, F11, F12, F2, or Esc as the PC
boots up. This Boot menu will display a list of drives you can boot from.[1]
If you are using an older PC that does not have a Boot menu, you will need
to Enter the BIOS while booting up. The buttons you press to enter the BIOS is
different from one PC manufacturer to another. It will usually say what buttons
you need to press while your computer boots up. You typically need to
press F1 F2, F3, Esc or Delete to enter the BIOS.[2] You may need to be quick
about it. You can also reboot your PC into the BIOS from inside the Windows
Settings menu.
6
Select the USB drive. This is the drive that has the Windows Installation Media. This
will boot the PC from the Windows Installation Media. Once the computer boots from the
USB drive, press any key to start the Windows installation process.
If you are inside the BIOS settings. Locate the option that says "Boot", "Boot
order", "Priorities" or something similar. Change the boot order so that your PC
boots from the USB drive first. Then select the option to save and exit. This
will reboot your PC from the USB drive.
7
Select your language, time and currency, and keyboard input and click Next . Use
the drop-down menus to first select your language. Then select your country or region,
and your keyboard input method. Then click Next.
8
Click Install Now . It's the button in the center of the screen.
9
Enter your Windows product key and click Next . If you've already purchased
Windows, you can find your license key in your confirmation email. If you have not
purchased Windows, click I don't have a product key. You'll need to purchase
Windows and activate it later on.
10
Select which edition of Windows you want to install and click Next . If you've already
purchased Windows, check which version of Windows you purchased and make sure you
click the right version. If you have not yet purchased Windows, check which version you
want to install. Different versions of Windows have a different price.
If you are not sure which version of Windows to install, Windows Home
Edition is the most common version of Windows.
11
Click the checkbox next to "I accept the license terms" and click Next . You can read
the license terms in the window in the center. Click next when you are ready to continue.
12
Click Custom: Install Windows only or Upgrade: Install Windows and keep files,
settings, and applications . If your computer already has a Windows installation on it,
click Upgrade: Install Windows and keep files, settings, and applications. If your
computer does not have a Windows installation or you need to reinstall Windows,
click Custom: Install Windows only.
13
Select a drive or partition you want to install Windows on and click Delete . If you
have multiple hard drives or a hard drive with multiple partitions, select the partition you
want to install Windows on and click Delete. Be aware that this will erase all data on the
drive. Make sure you have backed up all data you want to keep before continuing. This
will leave the drive with unallocated space.
14
Select a drive with unallocated space and click Next . This will start installing
Windows on the drive you selected. The amount of time it takes will depend on the
hardware of your computer.
15
Remove the USB flash drive and restart your computer. Once Windows is finished
installing, your computer will restart automatically. Remove the USB flash drive
so that it does not try to boot from the Flash drive again. The first time Windows
boots up, you will need to go through the Setup process.
c. STEPS TO installation of Antivirus.
PRAC 11. What do you mean by Spooling Printers? Write the steps
for spooling printer.
Printers have a limited amount of memory, often times much smaller than the
size of a document that you are wanting to print.
Printer spooling allows you to send large documents, or multiple documents, to a
printer and not have to wait for it to finish printing before continuing on to your next task.
Steps for Spooling Printers
The print spooler helps your Windows computer interact with the printer, and orders the
print jobs in your queue. If you see any error message about the print spooler, this tool
has been corrupted or is failing to interact correctly with other software.
1.
Clear the Print Queue. This will often fix the problem on its own. It is also a requirement before
continuing to the steps below.[8]
Open the Services window (Windows key + R, type services.msc, press enter).
Select Print Spooler and click the Stop icon, if it is not stopped already.
Navigate to C:\Windows\system32\spool\PRINTERS and open this file. You may need
to show hidden files and/or enter an administrator's password.
Delete all contents inside the folder. Do not delete the PRINTERS folder itself. Note
that this will remove all current print jobs, so make sure no one on your network is using
the printer.
Return to the Services window, select Print Spooler, and click Start.
2 Update printer drivers. Your printer driver may be corrupted, causing the
spooler problems when it tries to handle faulty data from the printer.
Try updating your drivers first. If this doesn't solve the problem, continue to the
next step.
3.Delete your printer. Your printer software may be corrupted. This quick process will remove it
so you can start again with a fresh installation:[9]
4
Delete the printer driver. The driver must be uninstalled separately. Leave your Devices and
Printers window open, and make these changes:
Left-click any other printer icon, then click Print Server Properties on the top menu
bar.
In the Properties window, click the Drivers tab.
Select the driver for the deleted printer, then click Remove.
If you choose "Remove driver and driver package," the installation package will be
deleted as well. Only do this if you know where to find a new installation package for
that driver.
5
Reinstall your printer. Plug your printer back in and follow the onscreen instructions to reinstall
the printer. If you deleted the driver package, you will also need to download a replacement. Look
for this on the printer manufacturer's website.
6
Delete reappearing printers with Print Management. If your printer or driver keep
reappearing, or fail to uninstall, this tool can sometimes do the trick. It is only available for
Windows 7 Pro/Ultimate/Enterprise and Windows 8 Pro/Enterprise. Use it as follows:[10]
7
Click Printers in the left pane. Find the printer you're having trouble with in the right pane,
right-click it, and select "Delete."
Click Drivers in the left pane. Right-click each driver used by that printer, and select
"Delete" to uninstall it. (You will not be able to uninstall it if another printer is using it.)
Alternatively, right-click the driver and select "Remove Driver Package." This will
uninstall the driver and delete the installation package. This is sometimes necessary, but
you will not be able to reinstall the driver until you download a new installation
package.
Connect to the printer to reinstall it. Download a new driver if you removed the driver
package.
A distributed denial of service (DDoS) attack operates like its name implies; it’s a
form of cyber attack that disrupts connectivity or network services to deny service for
users. Attacks generally feature tools, such as a bot, that overwhelm the network with
repeated signals until it can no longer process genuine requests from users.
Additionally, establish an incident response team in case the DDoS is successful and
define responsibilities, such as notifying key stakeholders and ensuring communication
throughout the organization.
2. Secure your Infrastructure with DDoS Attack Prevention Solutions. Equip your
network, applications, and infrastructure with multi-level protection strategies. This may
include prevention management systems that combine firewalls, VPN, anti-spam, content
filtering and other security layers to monitor activities and identity traffic inconsistencies
that may be symptoms of DDoS attacks.
Assessments will secure your network by trying to find security vulnerabilities. This is
done by taking inventory of all devices on the network, as well as their purpose, system
information, and any vulnerabilities associated with them, and including what devices
need to be prepared for upgrades or future assessments. Doing so will help define your
organization’s level of risk so you can optimize any security investments.
4. Identify Warning Signs of a DDoS Attack. If you can identify the symptoms of a
DDoS attack as early as possible, you can take action and hopefully mitigate damage.
Spotty connectivity, slow performance, and intermittent web crashes are all signs that
your business may be coming under attack from a DDoS criminal. Educate your team on
signs of DDoS attacks so everyone can be alert for warning signs.
Not all DDoS attacks are extensive and high volume; low-volume attacks that launch for
short durations are just as common. These attacks can be particularly nefarious because
they are more likely to go under the radar as just a random incident rather than a potential
security breach. Low-volume DDoS attacks are likely distractions for damaging malware;
while your IT security staff is distracted by a low-volume attack, malicious software like
ransomware can infiltrate your network.
Cloud providers who offer high levels of cybersecurity, including firewalls and threat
monitoring software, can help protect your assets and network from DDoS criminals. The
cloud also has greater bandwidth than most private networks, so it is likely to fail if under
the pressure of increased DDoS attacks.
Bluetooth file transfer is a simple way to send files to another nearby Bluetooth device
without the need for a separate app. Bluetooth is compatible with smartphones, tablets,
laptops, and desktop computers. You can transfer files over Bluetooth using Android
OS, Fire OS, Windows OS, Mac OS, and Linux OS.
While macOS supports Bluetooth, file transfers with that system are managed by
AirDrop. Windows PCs are able to send files to a mobile device (and vice versa).
1. Open a file manager (on Windows, open File Explorer) and go to the folder that
contains the file you want to send.
2. Right-click the file.
4. Select Next and follow the prompts to rename the file, choose the Bluetooth
device, and send the file.
5. After several seconds, a notification appears on the receiving device.
6. Tap Accept on the receiving device to download the file.
7. Select Finish when the file transfer is complete.
To transfer files using FTP, you require to an FTP server, a user account, and an FTP
client or application. Generally, most FTP servers require a username and a password in
order to make a connection.
1. Username and password Login: This is a restrictive method where only users
with an account can access the server. This is common when there is a need for
users to upload or download files to and from the server.
2. Username only: Some sites only require a username to access. However, this will
only allow downloads and not uploads
3. Anonymous FTP access: This does not require the user to enter a username or
password and is the easiest. The access is usually for sites where users can only
download files such as forms, software, and others.
Once the process is complete, you will see a screen that shows the login names, path, and
quota. To see the details for each FTP account, click Configure FTP client. This will
show you the FTP username, server, and port.
Using an FTP Client to Transfer Files over FTP
Connections
Moving files is much easier when using an FTP client and you may consider one if you
require regular access to the FTP servers. Using these allows you to easily upload,
download or transfer files much easier than a command line or web browser. For the
purpose of this article, we will look at two FTP clients for Windows
A screen with two panes opens up after log successful logon. By default, the left-hand
pane is the local drive while the right is the root directory of the remote FTP location.
To upload files
1. Select the files on the left-hand pane. You can select one or more files or folders
using the control and shift buttons.
2. Click the Upload drop-down button to choose whether you just want to upload
normally, in the background or and whether to transfer the files and then delete
from the source location.
Alternatively, transfer and then right-click, it gives the same options as clicking on the
drop-down button.
Use FTP Rush to Transfer Files Between Two Servers
The FTP Rush works almost the same way as the WinSCP. However, it has the option of
transferring files between two remote servers.
By default FTP Rush displays a local directory on the left pane and the remote on the
right pane. However, you can switch these the way you want them as well as connect to
two remote servers. If you want two remote servers, click on the computer /server on the
icons bar under the name Local.
4. To connect to remote machine, click on the (2) Remote bar.
5. At the top of the page, enter the Host name, port, FTP Username and Password,
and the Path. Click the quick connect button just before the Host, or
press Enter key to connect. Alternatively, click on the drop-down button between
the connect button and Host to open Quick Connect dialog box. Enter the details
FTP details and click OK to connect.
Alternatively, click the connect/disconnect icon and enter the details.
To copy files between different computers or server, go to the correct pane select the files
you want to upload to download and then click the Transfer button (Green arrow).
Right-clicking on the highlighted files will also give you the Transfer and other options
such as Delete, Make directory, Advanced Transfer, etc.
To upload files, select the files from your Local pane and click the transfer arrow.
To download files from the server to local, select the files in the Remote pane and click
transfer arrow.
To transfer files between two remote servers,
1. Go to the Local drive pane and click the icon to switch to remote.
2. Enter the FTP username and password for the second website and click OK.
3. Once you establish a connection to each server, select and transfer the files you
want to copy to the other server.
PRAC 13 : Write a program to check the strength of the password.
#include<stdio.h>
#include<string.h>
#include<ctype.h>
main()
{
char password[100],alpha,digit,special,i;
printf("Enter your Passwordn");
gets(password);
for(i=0; password[i]!=‘0’; i++)
{
if(isalpha(password[i])!=0) alpha++;
else if(isdigit(password[i]!=0)
digit++;
else special++;
}
{
if(alpha>0 && digit>0 && special>0)
printf(“Great! Your password is strongn”);
else if(alpha>0 && digit>0)
printf(“Your password is moderaten We recommend you to add
some special charactersn”); else
printf(“your password is Weak! Please Enter againn”);
}
Output
Strength of password:-Strong
12. Write a program to identify the category of IP address for a given IP
address.
An IPv4 has 4 octets having decimal value between 0 to 255 and depending on
the first octet’s value, IP Addresses divided into 5 classes: (Read more: IP Address
and Its classes)
Class A 1 to 126
Class B 128 to 191
Class C 192 to 223
Class D 224 to 239
Class E 240 to 254
#include <string.h>
/*
Function : extractIpAddress
Arguments :
2) ipAddress - Target variable short type array pointer that will store ip
address octets
*/
len=strlen(sourceString);
for(i=0;i<len;i++)
{
if(sourceString[i]!='.'){
buf[cnt++] =sourceString[i];
if(sourceString[i]=='.' || i==len-1){
buf[cnt]='\0';
cnt=0;
oct[cnt1++]=atoi(buf);
ipAddress[0]=oct[0];
ipAddress[1]=oct[1];
ipAddress[2]=oct[2];
ipAddress[3]=oct[3];
int main()
short ipAddress[4];
scanf("%s",ip);
extractIpAddress(ip,&ipAddress[0]);
printf("\nIp Address: %03d. %03d. %03d.
%03d\n",ipAddress[0],ipAddress[1],ipAddress[2],ipAddress[3]);
printf("Class A Ip Address.\n");
printf("Class B Ip Address.\n");
printf("Class C Ip Address.\n");
printf("Class D Ip Address.\n");
if(ipAddress[0]>239)
printf("Class E Ip Address.\n");
return 0;
}
Output
#include <string.h>
int M = strlen(pat);
int N = strlen(txt);
int i = 0;
while (i <= N - M) {
int j;
if (txt[i + j] != pat[j])
break;
i = i + M;
else if (j == 0)
i = i + 1;
else
i = i + j; // slide the pattern by j
int main()
search(pat, txt);
return 0;
}
Output:
Pattern found at index 4
Pattern found at index 12
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <time.h>
int IP[] =
{
58, 50, 42, 34, 26, 18, 10, 2,
60, 52, 44, 36, 28, 20, 12, 4,
62, 54, 46, 38, 30, 22, 14, 6,
64, 56, 48, 40, 32, 24, 16, 8,
57, 49, 41, 33, 25, 17, 9, 1,
59, 51, 43, 35, 27, 19, 11, 3,
61, 53, 45, 37, 29, 21, 13, 5,
63, 55, 47, 39, 31, 23, 15, 7
};
int E[] =
{
32, 1, 2, 3, 4, 5,
4, 5, 6, 7, 8, 9,
8, 9, 10, 11, 12, 13,
12, 13, 14, 15, 16, 17,
16, 17, 18, 19, 20, 21,
20, 21, 22, 23, 24, 25,
24, 25, 26, 27, 28, 29,
28, 29, 30, 31, 32, 1
};
int P[] =
{
16, 7, 20, 21,
29, 12, 28, 17,
1, 15, 23, 26,
5, 18, 31, 10,
2, 8, 24, 14,
32, 27, 3, 9,
19, 13, 30, 6,
22, 11, 4, 25
};
int FP[] =
{
40, 8, 48, 16, 56, 24, 64, 32,
39, 7, 47, 15, 55, 23, 63, 31,
38, 6, 46, 14, 54, 22, 62, 30,
37, 5, 45, 13, 53, 21, 61, 29,
36, 4, 44, 12, 52, 20, 60, 28,
35, 3, 43, 11, 51, 19, 59, 27,
34, 2, 42, 10, 50, 18, 58, 26,
33, 1, 41, 9, 49, 17, 57, 25
};
int S1[4][16] =
{
14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7,
0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8,
4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0,
15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13
};
int S2[4][16] =
{
15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10,
3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5,
0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15,
13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9
};
int S3[4][16] =
{
10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8,
13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1,
13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7,
1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12
};
int S4[4][16] =
{
7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15,
13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9,
10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4,
3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14
};
int S5[4][16] =
{
2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9,
14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6,
4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14,
11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3
};
int S6[4][16] =
{
12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11,
10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8,
9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6,
4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13
};
int S7[4][16]=
{
4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1,
13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6,
1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2,
6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12
};
int S8[4][16]=
{
13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7,
1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2,
7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8,
2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11
};
int PC1[] =
{
57, 49, 41, 33, 25, 17, 9,
1, 58, 50, 42, 34, 26, 18,
10, 2, 59, 51, 43, 35, 27,
19, 11, 3, 60, 52, 44, 36,
63, 55, 47, 39, 31, 23, 15,
7, 62, 54, 46, 38, 30, 22,
14, 6, 61, 53, 45, 37, 29,
21, 13, 5, 28, 20, 12, 4
};
int PC2[] =
{
14, 17, 11, 24, 1, 5,
3, 28, 15, 6, 21, 10,
23, 19, 12, 4, 26, 8,
16, 7, 27, 20, 13, 2,
41, 52, 31, 37, 47, 55,
30, 40, 51, 45, 33, 48,
44, 49, 39, 56, 34, 53,
46, 42, 50, 36, 29, 32
};
int SHIFTS[] = { 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1 };
FILE* out;
int LEFT[17][32], RIGHT[17][32];
int IPtext[64];
int EXPtext[48];
int XORtext[48];
int X[8][6];
int X2[32];
int R[32];
int key56bit[56];
int key48bit[17][48];
int CIPHER[64];
int ENCRYPTED[64];
int F1(int i)
{
int r, c, b[6];
r = b[0] * 2 + b[5];
c = 8 * b[1] + 4 * b[2] + 2 * b[3] + b[4];
if (i == 0) {
return S1[r][c];
}
else if (i == 1) {
return S2[r][c];
}
else if (i == 2) {
return S3[r][c];
}
else if (i == 3) {
return S4[r][c];
}
else if (i == 4) {
return S5[r][c];
}
else if (i == 5) {
return S6[r][c];
}
else if (i == 6) {
return S7[r][c];
}
else if (i == 7) {
return S8[r][c];
}
}
if (i % 32 == 0) {
i = 0;
}
i = i + 4;
}
int value;
for (int i = 0; i < 8; i++)
{
value = F1(i);
ToBits(value);
}
}
SBox(XORtext);
void convertToBinary(int n)
{
int k, m;
for (int i = 7; i >= 0; i--)
{
m = 1 << i;
k = n & m;
if (k == 0) {
fprintf(out, "0");
}
else {
fprintf(out, "1");
}
}
}
while (i)
{
ch = fgetc(inp);
if (ch == -1) {
break;
}
i--;
convertToBinary(ch);
}
fclose(out);
fclose(inp);
}
fclose(out);
}
int bittochar()
{
out = fopen("result.txt", "ab+");
for (int i = 0; i < 64; i = i + 8) {
convertToBits(&ENCRYPTED[i]);
}
fclose(out);
}
k = 0;
for (int i = 28 – shift; i < 28; i++) {
C[x][i] = backup[x – 1][k++];
}
k = 0;
for (int i = 28 – shift; i < 28; i++) {
D[x][i] = backup[x – 1][k++];
}
}
while (!feof(in))
{
ch = getc(in);
plain[++i] = ch – 48;
}
fclose(in);
}
while (!feof(in))
{
ch = getc(in);
plain[++i] = ch – 48;
}
fclose(in);
}
void create16Keys()
{
FILE* pt = fopen("key.txt", "rb");
unsigned int key[64];
int i = 0, ch;
while (!feof(pt))
{
ch = getc(pt);
key[i++] = ch – 48;
}
key64to48(key);
fclose(pt);
}
return size;
}
int main()
{
// destroy contents of these files (from previous runs, if any)
out = fopen("result.txt", "wb+");
fclose(out);
create16Keys();
encrypt(n);
decrypt(n);
return 0;
}
OUTPUT FILE:
TEMP FILES:
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <errno.h>
#include <arpa/inet.h>
int main(void)
{
char domain[] = "www.sstatic.net",
path[]="stackexchange/img/logos/so/so-logo-med.png"; //example
int sock, bytes_received;
char send_data[1024],recv_data[9999], *p;
struct sockaddr_in server_addr;
struct hostent *he;
FILE *fp;
he = gethostbyname(domain);
if (he == NULL){
herror("gethostbyname");
exit(1);
}
if ((sock = socket(AF_INET, SOCK_STREAM, 0))== -1){
perror("Socket");
exit(1);
}
server_addr.sin_family = AF_INET;
server_addr.sin_port = htons(80);
server_addr.sin_addr = *((struct in_addr *)he->h_addr);
bzero(&(server_addr.sin_zero),8);
if (connect(sock, (struct sockaddr *)&server_addr,sizeof(struct sockaddr))
== -1){
perror("Connect");
exit(1);
}
fp=fopen("received_file","wb");
fwrite(p,strlen(p),1,fp);
close(sock);
fclose(fp);
return 0;
}
Prac 33. Write an algorithm and program for encrypting a plain text
and decrypting a cipher text using Caeser Cipher.
It is one of the simplest encryption technique in which each character in plain text is replaced
by a character some fixed number of positions down to it.
For example, if key is 3 then we have to replace character by another character that is 3
position down to it. Like A will be replaced by D, C will be replaced by F and so on.
Encryption
#include<stdio.h>
int main()
{
char message[100], ch;
int i, key;
printf("Enter a message to encrypt: ");
gets(message);
printf("Enter key: ");
scanf("%d", &key);
for(i = 0; message[i] != '\0'; ++i){
ch = message[i];
if(ch >= 'a' && ch <= 'z'){
ch = ch + key;
if(ch > 'z'){
ch = ch - 'z' + 'a' - 1;
}
message[i] = ch;
}
else if(ch >= 'A' && ch <= 'Z'){
ch = ch + key;
if(ch > 'Z'){
ch = ch - 'Z' + 'A' - 1;
}
message[i] = ch;
}
}
printf("Encrypted message: %s", message);
return 0;
}
Output
Decryption
#include<stdio.h>
int main()
{
char message[100], ch;
int i, key;
printf("Enter a message to decrypt: ");
gets(message);
printf("Enter key: ");
scanf("%d", &key);
for(i = 0; message[i] != '\0'; ++i){
ch = message[i];
if(ch >= 'a' && ch <= 'z'){
ch = ch - key;
if(ch < 'a'){
ch = ch + 'z' - 'a' + 1;
}
message[i] = ch;
}
else if(ch >= 'A' && ch <= 'Z'){
ch = ch - key;
if(ch < 'A'){
ch = ch + 'Z' - 'A' + 1;
}
message[i] = ch;
}
}
printf("Decrypted message: %s", message);
return 0;
}
Output
Prac 21: What is malware? Write the steps to remove the malware
from your PC.
1. Start (or restart) your Mac, then immediately press and hold the Shift
key. The Apple logo will appear on your display.
2. Release the Shift key when you see the login window (if you are
asked to log in twice, learn more about what to do here).
#include<stdio.h>
#include<math.h>
if (b == 1)
return a;
else
//Driver program
int main()
// of keys
return 0;
}
Output:
The value of P : 23
The value of G : 9
Digital Signature :
As the name sounds are the new alternative to sign a document digitally.
It ensures that the message is sent by the intended user without any
tampering by any third party (attacker). In simple words, digital signatures
are used to verify the authenticity of the message sent electronically.
RSA :
It is the most popular asymmetric cryptographic algorithm. It is primarily
used for encrypting message s but can also be used for performing digital
signature over a message.
An RSA algorithm is an important and powerful algorithm in
cryptography. It is widely used in Digital Signature and in an SSL. The
algorithm works in the following way
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
typedef struct {
int d;
int x;
int y;
} EE;
EE extended_euclid(int a, int b) {
if (b == 0) {
ee1.d = a;
ee1.x = 1;
ee1.y = 0;
return ee1;
} else {
ee3.d = ee2.d;
ee3.x = ee2.y;
return ee3;
// Copied from
// https://stackoverflow.com/questions/11720656/modulo-operation-with-
negative-numbers
return (x % N + N) % N;
int result, i = 0;
do{
result = op1 % 2;
op1 /= 2;
aOp[i] = result;
i++;
int *bb;
int count = 0, c = 0, d = 1, i;
decimal_to_binary(b, bb);
c = 2 * c;
d = (d*d) % n;
if (bb[i] == 1) {
c = c + 1;
d = (d*a) % n;
return d;
EE ee;
ee = extended_euclid(e, phi);
int p, q, phi, n, e, d, m, c;
scanf("%d", &p);
scanf("%d", &q);
n = p*q;
phi = (p - 1) * (q - 1);
printf("Enter the value of e: ");
scanf("%d", &e);
d = get_d(e, phi);
scanf("%d", &m);
c = modular_exponentiation(m, e, n);
m = modular_exponentiation(c, d, n);
return 0;