0% found this document useful (0 votes)
5 views11 pages

is code

The document outlines various cryptographic algorithms including Caesar Cipher, columnar transposition, substitution and transposition, and RSA, along with their implementations in C programming. It also provides definitions and examples for networking and cybersecurity terms such as MD5, SHA1, WHOIS, and SMTP. Additionally, it includes a summary table for quick reference on the purpose and examples of the discussed terms.

Uploaded by

priya31patil0504
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views11 pages

is code

The document outlines various cryptographic algorithms including Caesar Cipher, columnar transposition, substitution and transposition, and RSA, along with their implementations in C programming. It also provides definitions and examples for networking and cybersecurity terms such as MD5, SHA1, WHOIS, and SMTP. Additionally, it includes a summary table for quick reference on the purpose and examples of the discussed terms.

Uploaded by

priya31patil0504
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Practical 1: Design and Implement Caesar Cipher cryptographic

algorithm by considering letter [A….Z] and digits.

#include <stdio.h>

#include <string.h>

#include <ctype.h>

int main()

char plaintext[100];

char ciphertext[100];

int key, i, length;

printf("Enter a plain text: ");

scanf("%s", plaintext);

printf("Enter key: ");

scanf("%d", &key);

length = strlen(plaintext);

for(i = 0; i < length; i++)

char c = toupper(plaintext[i]);

if(c >= 'A' && c <= 'Z')

ciphertext[i] = (c - 'A' + key) % 26 + 'A';

else if(c >= '0' && c <= '9')

{
ciphertext[i] = (c - '0' + key) % 10 + '0';

else

ciphertext[i] = c;

ciphertext[i] = '\0';

printf("Plaintext: %s\n", plaintext);

printf("Ciphertext: %s\n", ciphertext);

return 0;

Apply Brute Force Attack on Caesar Cipher Algorithm to reveal

#include <stdio.h>

#include <string.h>

int main() {

char ciphertext[100];

printf("Enter Ciphertext: ");

scanf("%s", ciphertext);

for (int key = 0; key < 26; key++) {

printf("\nKey: %d, Plaintext: ", key);

for (int i = 0; ciphertext[i]; i++) {

char c = ciphertext[i];

if (c >= 'A' && c <= 'Z')


c = (c - 'A' - key + 26) % 26 + 'A';

else if (c >= 'a' && c <= 'z')

c = (c - 'a' - key + 26) % 26 + 'a';

else if (c >= '0' && c <= '9')

c = (c - '0' - key + 10) % 10 + '0';

putchar(c);

return 0;

2.Simple columnar transposition

#include <stdio.h>

#include <string.h>

int main() {

char msg[] = "HELLOWORLD";

int key = 3;

int len = strlen(msg);

char enc[100], dec[100];

// Encryption

int k = 0;

for (int col = 0; col < key; col++)

for (int i = col; i < len; i += key)

enc[k++] = msg[i];

enc[k] = '\0';
printf("Original: %s\n", msg);

printf("Encrypted: %s\n", enc);

// Decryption

int rows = (len + key - 1) / key;

int idx = 0;

for (int col = 0; col < key; col++)

for (int i = col; i < len; i += key)

dec[i] = enc[idx++];

dec[len] = '\0';

printf("Decrypted: %s\n", dec);

return 0;

}
3. Substitution and transposition
#include <stdio.h>
#include <string.h>

Int main() {
Char msg[] = “HELLO”, enc[100], dec[100];
Int key = 3, len = strlen(msg), k = 0;

// Encrypt (Substitution + Transposition)


For (int col = 0; col < key; col++)
For (int i = col; i < len; i += key)
Enc[k++] = msg[i] + 1;
Enc[k] = ‘\0’;

Printf(“Encrypted: %s\n”, enc);

// Decrypt (Reverse Transposition + Substitution)


K = 0;
For (int col = 0; col < key; col++)
For (int i = col; i < len; i += key)
Dec[i] = enc[k++] – 1;
Dec[len] = ‘\0’;

Printf(“Decrypted: %s\n”, dec);


Return 0;
}

4RSA
#include <stdio.h>

Int main() {
Int p, q, e, d, n, phi, msg, enc = 1, dec = 1;

Printf(“Enter two primes p and q: “);


Scanf(“%d %d”, &p, &q);

N = p * q;
Phi = (p – 1) * (q – 1);

Printf(“Enter encryption key e (e.g., 7): “);


Scanf(“%d”, &e);

// Find d such that (d * e) % phi == 1


For (d = 1; d < phi; d++) {
If ((d * e) % phi == 1)
Break;
}

Printf(“Enter message (as number): “);


Scanf(“%d”, &msg);

// Encryption: c = (msg^e) % n
For (int i = 0; i < e; i++)
Enc = (enc * msg) % n;

// Decryption: m = (enc^d) % n
For (int i = 0; i < d; i++)
Dec = (dec * enc) % n;
Printf(“Encrypted message: %d\n”, enc);
Printf(“Decrypted message: %d\n”, dec);

Return 0;
}

Sure! Here's a simple definition and example for each of the following: MD5, SHA1, WHOIS,
DIG, TRACERT, and NSLOOKUP.

🔐 1. MD5 (Message Digest 5)


Definition:
MD5 is a cryptographic hash function that takes input data and produces a fixed 128-bit (32-
character) hash value. It is commonly used to verify data integrity.
Example:
$ echo "hello" | md5sum
5d41402abc4b2a76b9719d911017c592

🔐 2. SHA1 (Secure Hash Algorithm 1)


Definition:
SHA1 is a hash function that produces a 160-bit (40-character) hash. It was used for data
integrity and digital signatures but is now considered insecure.
Example:
$ echo "hello" | sha1sum
aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d

🌐 3. WHOIS
Definition:
WHOIS is a command-line tool or protocol used to find information about a domain name, such
as the owner's name, registrar, creation/expiry date, etc.
Example:
$ whois google.com
Output (shortened):
Domain Name: GOOGLE.COM
Registrar: MarkMonitor Inc.
Creation Date: 1997-09-15
Expiry Date: 2028-09-14
🌍 4. DIG (Domain Information Groper)
Definition:
DIG is used to query DNS servers for information about a domain like IP address, mail servers,
etc. It helps troubleshoot DNS issues.
Example:
$ dig google.com
Output (shortened):
;; ANSWER SECTION:
google.com. 299 IN A 142.250.77.206

5. TRACERT (Windows) / traceroute (Linux)


Definition:
Tracert shows the path (hops) that packets take from your computer to a destination server. Helps
in finding where a network problem occurs.
Example:
$ tracert google.com
Output (shortened):
1 192.168.1.1
2 10.0.0.1
3 142.250.77.206 (google.com)

🔎 6. NSLOOKUP
Definition:
NSLOOKUP is a command-line tool used to find the IP address of a domain name or get DNS
information.
Example:
$ nslookup google.com
Output:
Name: google.com
Address: 142.250.77.206

Let me know if you want a printable table or PDF for this!


Here are simple definitions with examples for the terms you mentioned, commonly used in
networking and cybersecurity:

1. ICMP (Internet Control Message Protocol)


Definition:
ICMP is used by network devices to send error messages or status information. It’s the protocol
used by the ping command.
Example:
$ ping google.com
➡️ICMP sends echo request/reply to check if a host is reachable.

🔗 2. TCP (Transmission Control Protocol)


Definition:
TCP is a connection-oriented protocol that ensures reliable communication between devices over
the internet.
Example:
 Used by protocols like HTTP, FTP, SMTP, etc.
 Port 80 (HTTP), Port 443 (HTTPS)
➡️Guarantees data delivery (retransmits if lost).

🌐 3. HTTP (HyperText Transfer Protocol)


Definition:
HTTP is the protocol used to load webpages over the internet. It is not encrypted.
Example:
http://example.com
➡️Data sent in plain text. Not secure.

🔒 4. HTTPS (HTTP Secure)


Definition:
HTTPS is HTTP with encryption (via SSL/TLS), providing secure communication between
browser and server.
Example:
https://example.com
➡️Secure, data is encrypted in transit.

⚠️5. XSS (Cross-Site Scripting)


Definition:
XSS is a security vulnerability where an attacker injects malicious scripts into a trusted website,
which run in the user’s browser.
Example:
<script>alert('Hacked!');</script>
➡️If injected into a comment box, it can steal cookies or session data.
💥 6. Buffer Overflow
Definition:
A buffer overflow happens when a program writes more data to a memory block (buffer) than it
can hold, potentially allowing code execution.
Example:
Supplying too much input to:
char name[10];
gets(name); // vulnerable to overflow
➡️Can crash the program or let attackers run their own code.

7. SQL Injection
Definition:
SQL Injection is a web attack where malicious SQL code is injected into input fields to
manipulate the database.
Example:
' OR '1'='1
➡️Input like this can bypass login systems or leak data.

💉 8. Injector
Definition:
"Injector" is a general term for any tool or method that injects code or data into a system or
application, often used for exploits (like SQLi, XSS, DLL injection, etc.).
Example:
 SQL Injector tool
 DLL Injector for modifying running programs
➡️Injectors are commonly used in hacking or penetration testing.

Let me know if you want visuals, PDF notes, or a comparison table!


Here are simple definitions and examples for SMTP, ARP, and Wireshark — commonly used
in networking:

📤 1. SMTP (Simple Mail Transfer Protocol)


Definition:
SMTP is the protocol used to send emails from a client to a server or between email servers.
Use Case:
Sending an email from Gmail to Yahoo or Outlook.
Port Numbers:
 Port 25 (default)
 Port 587 (secure with TLS)
 Port 465 (SSL)
Example:
Email client → SMTP → Mail Server
Command-Line Example (simplified):
telnet smtp.gmail.com 587

🔁 2. ARP (Address Resolution Protocol)


Definition:
ARP maps a known IP address to its MAC address in a local network.
Use Case:
When your computer knows the IP address (like 192.168.1.1) but needs the MAC address to
send data.
Example:
$ arp -a
Output:
192.168.1.1 00-14-22-01-23-45 dynamic
➡️Your computer asks: “Who has 192.168.1.1?” and the router replies with its MAC.

3. Wireshark
Definition:
Wireshark is a network protocol analyzer used to capture and inspect packets of data flowing
through a network in real time.
Use Case:
 Debugging network problems
 Viewing packet-level details of TCP, HTTP, DNS, etc.
 Detecting suspicious activity or attacks
Example:
 Open Wireshark
 Start capture on Wi-Fi or Ethernet
 Filter: http, icmp, tcp.port == 80
Screenshot Output (typical):
No. Time Source Destination Protocol Info
1 0.000 192.168.1.2 8.8.8.8 DNS Standard query A
google.com

✅ Summary Table:
Term Purpose Type Example Use

SMTP Sends emails Protocol Gmail sending an email


Term Purpose Type Example Use

Network
ARP IP ↔ MAC address mapping Sending data in LAN
tool

Wiresha Captures and analyzes Tool/ Troubleshooting or


rk network packets software network analysis

Let me know if you want a mini project or practical demo using these!

You might also like