practical 7-10
practical 7-10
DESCRIPTION:
DES is a symmetric encryption system that uses 64-bit blocks, 8 bits of which
are used for parity checks. The key therefore has a "useful" length of 56 bits, which
means that only 56 bits are actually used in the algorithm. The algorithm involves
carrying out combinations, substitutions and permutations between the text to be
encrypted and the key, while making sure the operations can be performed in both
directions. The key is ciphered on 64 bits and made of 16 blocks of 4 bits, generally
denoted k1 to k16. Given that "only" 56 bits are actually used for encrypting, there can
be 256 different keys.
EXAMPLE:
ALGORITHM:
STEP-2: Split it into two 32-bit blocks and store it in two different arrays.
STEP-3: Perform XOR operation between these two arrays.
STEP-4: The output obtained is stored as the second 32-bit sequence and the
original second 32-bit sequence forms the first part.
STEP-5: Thus the encrypted 64-bit cipher text is obtained in this way. Repeat the
same process for the remaining plain text characters.
PROGRAM:
DES.java
import javax.swing.*;
import
java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import java.util.Random ;
class DES {
byte[] skey = new
byte[1000]; String
skeyString;
static byte[] raw;
String inputMessage,encryptedData,decryptedMessage;
public DES()
{
try
generateSymmetricKey();
inputMessage=JOptionPane.showInputDialog(null,"Enter
message to encrypt");
byte[] ibyte = inputMessage.getBytes();
byte[] ebyte=encrypt(raw, ibyte);
System.out.println(e);
}
void generateSymmetricKey()
{ try {
Random r = new Random();
int num =
r.nextInt(10000);
String knum =
String.valueOf(num); byte[]
knumb = knum.getBytes();
skey=getRawKey(knumb);
skeyString = new String(skey);
System.out.println("DES Symmetric key = "+skeyString);
catch(Exception e)
System.out.println(e);
SecretKey skey =
kgen.generateKey(); raw =
skey.getEncoded();
return raw;
Thus the data encryption standard algorithm had been implemented successfully
using C language.
PRACTICAL: 8
8. write a C program to implement the RSA encryption algorithm.
DESCRIPTION:
(me)d = m (mod n)
The public key is represented by the integers n and e; and, the private key, by
the integer d. m represents the message. RSA involves a public key and a private key.
The public key can be known by everyone and is used for encrypting messages. The
intention is that messages encrypted with the public key can only be decrypted in a
reasonable amount of time using the private key.
EXAMPLE:
ALGORITHM:
PROGRAM: (RSA)
#include<stdio.h>
#include<conio.h>
#include<stdlib.h
>
#include<math.h>
#include<string.h
>
long int
p,q,n,t,flag,e[100],d[100],temp[100],j,m[100],en[100]
,i; char msg[100];
int prime(long
int); void ce();
void decrypt();
void main()
{
clrscr();
printf("\nENTER FIRST PRIME NUMBER\n");
scanf("%d",&p);
flag=prime(p);
if(flag==0)
{
printf("\nWRONG INPUT\
n"); getch();
}
printf("\nENTER ANOTHER PRIME NUMBER\n");
scanf("%d",&q);
flag=prime(q);
if(flag==0||p==q)
{
printf("\nWRONG INPUT\n");
getch();
}
printf("\nENTER MESSAGE\
n"); fflush(stdin);
scanf("%s",msg);
for(i=0;msg[i]!=NULL;i++)
m[i]=msg[i];
n=p*q;
t=(p-1)*(q-1);
ce();
encrypt()
;
decrypt()
;
getch();
}
int i;
j=sqrt(pr);
for(i=2;i<=j;i+
+)
{
if(pr%i==0)
return 0;
return 1;
void ce()
int k;
k=0;
for(i=2;i<t;i++)
{
if(t%i==0)
continue;
flag=prime(i);
if(flag==1&&i!=p&&i!=q)
{
e[k]=i;
flag=cd(e[k]);
if(flag>0)
{
d[k]=flag;
k++;
}
if(k==99)
break;
} } }
k=k+t; if(k
%x==0)
return(k/x)
;
} }
void encrypt() {
long int
pt,ct,key=e[0],k,len; i=0;
len=strlen(msg);
while(i!=len) {
pt=m[i];
pt=pt-96;
k=1;
for(j=0;j<key;j++)
{ k=k*pt;
k=k%n;
}
temp[i]=k;
ct=k+96;
en[i]=ct;
i++;
}
en[i]=-1;
for(i=0;en[i]!=-1;i++)
printf("%c",en[i]);
void decrypt()
long int
pt,ct,key=d[0],k; i=0;
while(en[i]!=-1)
ct=temp[i];
k=1;
for(j=0;j<key;j++)
k=k*ct; k=k
%n;
}
pt=k+96
;
m[i]=pt
; i++;
}
m[i]=-1;
for(i=0;m[i]!=-1;i++)
printf("%c",m[i]);
}
PROF.DEVANSHI DAVE
OUTPUT:
RESULT: Thus the C program to implement RSA encryption technique had been
implemented successfully
PROF.DEVANSHI DAVE
PRACTICAL: 9
A firewall is a hardware or software network security device that monitors all incoming and
outgoing traffic based on a defined set of security rules, it accepts, rejects, or drops that
specific traffic.
Accept: Allow traffic.
Reject: Block traffic but respond with “reachable error”.
Drop: Block unanswered traffic firewall establishes a barrier between secure internal
networks and untrusted external networks, such as the Internet.
Step 1: First, open the Cisco packet tracer desktop and select the devices given below:
S.N
O Device Model Name Quantity
1. PC PC 3
2. server PT-Server 1
3. switch PT-Switch 1
IP Addressing Table:
Pause
Unmute
×
PROF.DEVANSHI DAVE
S.N
O Device IPv4 Address Subnet Mask
Step 2: Configure the PCs (hosts) and server with IPv4 address and Subnet Mask
according to the IP addressing table given above.
To assign an IP address in PC0, click on PC0.
Then, go to desktop and then IP configuration and there you will IPv4
configuration.
PROF.DEVANSHI DAVE
Repeat the same procedure with other PCs to configure them thoroughly.
Step 3: Configuring the firewall in a server and blocking packets and allowing web
browser.
Click on server0 then go to the desktop.
Then click on firewall IPv4.
Turn on the services.
First, Deny the ICMP protocol and set remote IP to 0.0.0.0 and Remote wildcard
mask to 255.255.255.255.
Then, allow the IP protocol and set remote IP to 0.0.0.0 and Remote wildcard
mask to 255.255.255.255.
And add them.
PROF.DEVANSHI DAVE
PRACTICAL: 10
Defining Cybersecurity
Cybersecurity protects computer systems, networks, and data from unauthorised access,
damage, or theft in the digital world. It involves measures and technologies designed to
safeguard information and prevent malicious activities.
Cybersecurity aims to ensure data and systems' confidentiality, integrity, and availability,
keeping them safe from unauthorised access, manipulation, or disruption. Techniques like
encryption, firewalls, antivirus software, and user authentication are used to establish
barriers and secure digital assets from potential risks.
In today's digital age, cybersecurity is crucial in keeping our digital lives safe and secure.
It's like having a virtual bodyguard that protects our computers, smartphones, and other
devices from bad guys who try to steal our information or cause harm.
Think about all the personal data we store on our devices - photos, emails, banking details,
and private conversations. Cybersecurity ensures this information remains private and
protected from unauthorised access. Companies store sensitive customer data, financial
records, and proprietary information. Without proper cybersecurity measures, hackers could
steal or tamper with this information.
Cybersecurity also helps in maintaining the smooth functioning of digital systems. Imagine
if a major website or online service gets hacked or disrupted. It could lead to chaos for
users. Cybersecurity helps prevent such disruptions and keep things running smoothly.
PROF.DEVANSHI DAVE
Cybersecurity is like a shield that protects our digital lives from cybercriminals. It ensures
the safety of our personal information, helps businesses secure sensitive data, maintains the
smooth functioning of digital systems, and safeguards our privacy in our connected world.
In the ever-evolving world of cybersecurity, there are several threats and risks that we need
to be aware of. Let's dive into a few of them.
Malware Monsters
One of the biggest threats is malware, which includes viruses, worms, and ransomware.
These sneaky little monsters can infect your devices and wreak havoc by stealing your data,
encrypting your files, or even taking control of your device.
Phishing Pirates
Beware of phishing attacks! These are like deceptive messages from cyber pirates trying to
trick you into revealing sensitive information, such as passwords, credit card details, or
personal data. They often disguise themselves as trustworthy entities like banks or well-
known companies.
If your devices or networks have weak security settings or outdated software, you open the
castle gates for cyber intruders. They can exploit vulnerabilities in your systems and gain
unauthorised access to your sensitive data.
The IoT poses new risks with the increasing number of interconnected smart devices.
Insecure IoT devices can be gateways for cyber attackers to infiltrate your network, access
personal information, or even control connected devices like cameras or thermostats.
Insider Threats
Not all threats come from external sources. Insider threats involve individuals within an
organisation who misuse their access privileges or intentionally steal or leak sensitive data.
It could be a disgruntled employee or someone who has fallen victim to social engineering
tactics.
PROF.DEVANSHI DAVE
These are just a few examples of the threats and risks that cybersecurity faces today. It's
important to stay vigilant, keep your devices and software up to date, use strong passwords,
be cautious with suspicious emails or messages, and educate yourself about best
cybersecurity practices to protect yourself digitally.
Mitigation Strategies
Companies adopt various mitigation strategies to prevent cyberattacks and protect their
sensitive data and systems. Some common strategies include:
Companies employ firewalls, intrusion detection systems (IDS), and intrusion prevention
systems (IPS) to monitor and control incoming and outgoing network traffic. These
defences are a barrier against unauthorised access, and help identify and block potential
threats.
Companies maintain a proactive approach to patch management and software updates. They
ensure that all software, operating systems, and applications are regularly updated with the
latest security patches to address known vulnerabilities.
Data Encryption
PROF.DEVANSHI DAVE
Companies employ encryption techniques to protect sensitive data at rest and in transit.
Encryption helps ensure that even if data is intercepted or stolen, it remains unreadable and
unusable without the decryption keys.
PROF.DEVANSHI DAVE
Companies employ security monitoring tools and techniques to detect and respond to
potential threats in real-time. They also leverage threat intelligence sources to stay
informed about the latest threats and vulnerabilities, allowing them to implement preventive
measures proactively.