You are on page 1of 17

Computer Networks

Ex. No: 01

DATA LINK LAYER FRAMING METHODS


AIM To write a program for implementing the Data Link Layer framing methods such as character Count,character stuffing and bit stuffing DESCRIPTION

Data Link Layer Functions


Concerned with reliable, error-free and efficient communication between adjacent machines in the network through the following functions: 1 Data Framing: The term frame refers to a small block of data used in a specific network. The data link layer groups raw data bits to/from the physical layer into discrete frames with error detection/correction code bits added. Framing methods: Character count. Starting and ending characters, with character stuffing. -Starting and ending flags with bit stuffing. Physical layer coding violations. 2 Error Detection/Correction: Error Detection: Include enough redundant information in each frame to allow the receiver to deduce that an error has occurred, but not which error and to request a retransmission. Uses error-detecting codes. Error Correction: Include redundant information in the transmitted frame to enable the receiver not only to deduce that an error has occurred but also correct the error. Uses error-correcting codes. 3 Services to the network layer: Unacknowledged connectionless service: Independent frames sent without having the destination acknowledge them. Suitable for real-time data such as speech and video where transmission speed is more important than absolute reliability. Utilized in most LANS. Acknowledged connectionless service: Each frame sent is acknowledged by the receiver. Acknowledgment at the layer level is not essential but provides more efficiency than acknowledgment at higher layers (transport) which is done only for the whole message. A lost acknowledgment may cause a frame to be sent and received several times. Acknowledged connection-oriented service:

The sender and receiver establish a connection before any data transmission. The message is broken into numbered frames. The data link guarantees that each frame sent is received exactly once and in the right order. 4 Flow control Protocols to control the rate the sender transmits frames at a rate acceptable to the receiver, and the ability to retransmit lost or damaged frames. This insures that slow receivers are not swamped by fast senders and further aids error detection/correction. Several flow control protocols exist, but all essentially require a form of feedback to make the sender aware of whether the receiver can keep up. Stop-and-wait Protocols: A positive acknowledgment frame is send by the receiver to indicate that the frame has been received and to indicate being ready for the next frame. Positive Acknowledgment with Retransmission (PAR); uses timeouts Sliding Window Protocols: Data frames and acknowledgement frames are mixed in both directions. Frames sent contain sequence numbers Timeouts used to initiate retransmission of lost frames.

Placement of the data link protocol Data Link Layer: Framing 1. The character count method:
The frame header includes the count of characters in the frame A transmission error can cause an incorrect count causing the source and destination to get out of synchronization Rarely used in actual data link protocols.

Using Starting and ending characters, with character stuffing:


Each frame starts with the ASCII character sequence DLE (Data Link Escape) and STX (Start of TeXt) and ends with DLE ETX (End of TeXt) When binary data is transmitted where (DLE STX or DLE ETX) can occur in data, character stuffing is used (additional DLE is inserted in the data). Limited to 8-bit characters and ASCII.

2. Bit-Oriented Using Start/End Flags:


a. Each frame begins and ends with 01111110 b. Bit stuffing: After each five consecutive ones in a data a zero is stuffed c. Stuffed zero bits are removed by the data link layer at receiving end.

ROCEDURES Step-1: Print the menu as follows Character count -1 Character stuffing 2 Bit stuffing 3 Exit -4 Step-2: Read the Choice Step-3: If the choice is 1, do the following Read the Character sequence Use random( ) function for frame length If random() function returns 5 then Take the first 4 characters from the character stream and print the frame (for example: if first 4 characters are a,b,c,d then the frame is 5 a b c d) Repeat the above 2 steps until the character sequence ends Step-4: If the choice is 2, do the following Read the data units with delimiters DLE STX and DLE ETX Scan the data for any occurrences of delimiters like DLE If DLE found in the sequence, then stuff the another DLE Repeat the above 2 step until data stream ends. Step-5: If the choice is 3, do the following Read the bit stream Scan the bit stream for continuous 6 1s If it is found then insert 0 after 5th 1 Finally print the bit stream with delimiter 0 1 1 1 1 1 1 0 (i.e. 0 1 1 1 1 1 1 1 0 bit stream 0 1 1 1 1 1 1 0 ) Step-6: If the choice is 4 , then call exit() function. Implementation using C PROGRAM FOR CHARACTER STUFFING
#include<stdio.h> #include<conio.h> #include<string.h> #include<process.h> void main() { int i=0,j=0,n,pos;

char a[20],b[50],ch; clrscr(); printf("enter string\n"); scanf("%s",&a); n=strlen(a); printf("enter position\n"); scanf("%d",&pos); if(pos>n) { printf("invalid position, Enter again :"); scanf("%d",&pos); } printf("enter the character\n"); ch=getche(); b[0]='d'; b[1]='l'; b[2]='e'; b[3]='s'; b[4]='t'; b[5]='x'; j=6; while(i<n) { if(i==pos-1) { b[j]='d'; b[j+1]='l'; b[j+2]='e'; b[j+3]=ch; b[j+4]='d'; b[j+5]='l'; b[j+6]='e'; j=j+7; } if(a[i]=='d' && a[i+1]=='l' && a[i+2]=='e') { b[j]='d'; b[j+1]='l'; b[j+2]='e'; j=j+3; } b[j]=a[i]; i++; j++; } b[j]='d'; b[j+1]='l'; b[j+2]='e'; b[j+3]='e'; b[j+4]='t'; b[j+5]='x'; b[j+6]='\0'; printf("\nframe after stuffing:\n"); printf("%s",b); getch(); } INPUT: enter string: asdlefgh enter position: 8 invalid position,enter again: 3 enter the character: k

OUTPUT: frame after stuffing: dlestx as dle k dle dle dlefgh dleetx

PROGRAM FOR BIT STUFFING


#include<stdio.h> #include<conio.h> #include<string.h> void main() { int a[20],b[30],i,j,k,count,n; clrscr(); printf("Enter frame length:"); scanf("%d",&n); printf("Enter input frame (0's & 1's only):"); for(i=0;i<n;i++) scanf("%d",&a[i]); i=0; count=1; j=0; while(i<n) { if(a[i]==1) { b[j]=a[i]; for(k=i+1;a[k]==1 && k<n && count<5;k++) { j++; b[j]=a[k]; count++; if(count==5) { j++; b[j]=0; } i=k; }} else { b[j]=a[i]; } i++; j++; } printf("After stuffing the frame is:"); for(i=0;i<j;i++) printf("%d",b[i]); getch(); } INPUT: Enter frame length: 10 Enter input frame (0's & 1's only): 1 0 1 0 1 1 1 1 1 1 OUTPUT: After stuffing the frame is: 1 0 1 0 1 1 1 1 1 0 1

Ex. No: 02

CRC POLYNOMIALS
AIM To write a program for implementing on a data set characters the three CRC polynomials CSR12, CRC16 and CRC CCIP

DESCRIPTION

Data Link Layer: Error Detection/Correction


. Simplest error detection : Parity bits and checksum (sum of 1s in Data). . Error-detecting and -correcting codes: m data bits + r redundant bits added. n = m + r transmitted in frame. Only 2m code words out of possible 2m+r words are legal. The Hamming distance --minimum number of positions any two legal code words differ-- of a code defines its error detection/correction ability. To detect d errors code Hamming distance = d + 1 To correct d errors code Hamming distance = 2d + 1 Some codes are more suitable to correct burst errors rather than isolated errors. Polynomial codes: Cyclic Redundancy Check (CRC) Codes, are characterized by a generating polynomial G(X)

Cyclic Redundancy Check (CRC)


Based on polynomial arithmetic over finite field. View m-bit string a m-1a m-2 . . . a0 as a polynomial of degree m-1: M(x) = a m-1 x m-1 + a m-2 x m-2 + . + a0 Select a generating polynomial G(x) of degree r. Let R(x) be the remainder of xr M(x) / G(x) The code word T(x) of length m + r bit generated is then given by: T(x) = xr M(x) - R(x) Assume code word T(x) is transmitted, but T(x) + E(x) arrives at the receiver: If E(x) = 0 then no transmission errors and T(x)/G(x) = 0 If E(x) 0 then transmission error(s) occurred and: [T(x) + E(x)] / G(x) 0

Calculation of Polynomial Code (CRC) Checksum


1. For degree of generating polynomial G(x) = r , append r zero bits to low-order of frame. The frame now has m+r bits. 2. Divide the bit string corresponding to G(X) into the bit string xrM(x) mod(2) 3. Subtract the remainder R(x) from the bit string xrM(x) mod(2) Frame: 1 1 0 1 0 1 1 0 1 1 Generator: 1 0 0 1 1 G(X) = X4 + X + 1 Message after appending four 0s: 11010110110000 Remainder: 1110 Transmitted Frame: 11010110111110

Hardware Computation of CRC


For G(x) = x16 + x12 + x5 + 1

An Example Frame Format with CRC bits

Common CRC Generator Polynomials


CRC-32: x32 + x 26 + x 23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x + 1

Used in FDDI, Ethernet. CRC-CCITT: x16 + X12 + x5 + 1 Used in HDLC. CRC-8: x8 + x2 + x + 1 Used in ATM. PROCEDURES Step-1: Read the frame Step-2: Read the generator polynomial Step-3: find out the degree of the generator polynomial Step-4: Append the number of the zeros to the frame that number is equal to the degree of the polynomial Step-5: Find out number of digits in the generator polynomial Step-6: Repeat the following until the number of digits are exhausted Step-7: If the frame is starting with 1 , then exclusive-or the frame with generator Step-8: Check whether the result obtained in step 7 is starting with 1, If so exclusive-or the remainder with the generator Step-9: If the result obtained in step7 is starting with 0, then exclusive or the remainder(result) with zeros. The number of zeroes must be equal to the length of the generator. Implementation using C PROGRAM FOR CYCLIC REDUNDENCY CHECK
#include<stdio.h> #include<conio.h> int gen[4],genl,frl,rem[4]; void main() { int i,j,fr[8],dupfr[11],recfr[11],tlen,flag; clrscr(); frl=8; genl=4; printf("enter frame:"); for(i=0;i<frl;i++) { scanf("%d",&fr[i]); dupfr[i]=fr[i]; } printf("enter generator:"); for(i=0;i<genl;i++) scanf("%d",&gen[i]); tlen=frl+genl-1; for(i=frl;i<tlen;i++) { dupfr[i]=0; } remainder(dupfr); for(i=0;i<frl;i++) { recfr[i]=fr[i]; } for(i=frl,j=1;j<genl;i++,j++) { recfr[i]=rem[j]; } remainder(recfr); flag=0; for(i=0;i<4;i++) {

if(rem[i]!=0) flag++; } if(flag==0) { printf("frame received correctly"); } else { printf("the received frame is wrong"); } getch(); } remainder(int fr[]) { int k,k1,i,j; for(k=0;k<frl;k++) { if(fr[k]==1) { k1=k; for(i=0,j=k;i<genl;i++,j++) { rem[i]=fr[j]^gen[i]; } for(i=0;i<genl;i++) { fr[k1]=rem[i]; k1++; } } } } INPUT: enter frame : 1 1 1 1 1 1 1 1 enter generator : 1 1 0 1 OUTPUT: frame received correctly

Ex. No: 03

DIJIKSTRS ALGORITHM
AIM To write a program for implementation of Dijkstra's Algorithm to compute the shortest path through a graph DESCRIPTION Dijkstra's algorithm solves the single-source shortest-path problem when all edges have nonnegative weights. It is a greedy algorithm and similar to Prim's algorithm. Algorithm starts at the source vertex, s, it grows a tree, T, that ultimately spans all vertices reachable from S. Vertices are added to T in order of distance i.e., first S, then the vertex closest to S, then the next closest, and so on. Following implementation assumes that graph G is represented by adjacency lists.

DIJKSTRA (G, w, s)
1. INITIALIZE SINGLE-SOURCE (G, s) 2. S { } // S will ultimately contains vertices of final shortest-path weights from s 3. Initialize priority queue Q i.e., Q V[G] 4. while priority queue Q is not empty do

5. u EXTRACT_MIN(Q) // Pull out new vertex 6. S S {u} // Perform relaxation for each vertex v adjacent to u 7. for each vertex v in Adj[u] do 8. Relax (u, v, w) PROCEDURES Step1. Given initial graph G=(V, E). All nodes have infinite cost except the source node, s, which has 0 cost. Step 2. First we choose the node, which is closest to the source node, s. We initialize d[s] to 0. Add it to S. Relax all nodes adjacent to source, s. Update predecessor (see red arrow in diagram below) for all nodes updated. Step 3. Choose the closest node, x. Relax all nodes adjacent to node x. Update predecessors for nodes u, v and y (again notice red arrows in diagram below). Step 4. Now, node y is the closest node, so add it to S. Relax node v and adjust its predecessor (red arrows remember!). Step 5. Now we have node u that is closest. Choose this node and adjust its neighbor node v. Step 6. Finally, add node v. The predecessor list now defines the shortest path from each node to the source node, s. Implementation Using C PROGRAM FOR FINDING SHORTEST PATH FOR A GIVEN GRAPH
#include<stdio.h> #include<conio.h> void main() { int path[5][5],i,j,min,a[5][5],p,st=1,ed=5,stp,edp,t[5],index; clrscr(); printf("enter the cost matrix\n"); for(i=1;i<=5;i++) for(j=1;j<=5;j++) scanf("%d",&a[i][j]); printf("enter number of paths\n"); scanf("%d",&p); printf("enter possible paths\n"); for(i=1;i<=p;i++) for(j=1;j<=5;j++) scanf("%d",&path[i][j]); for(i=1;i<=p;i++) { t[i]=0; stp=st; for(j=1;j<=5;j++) { edp=path[i][j+1]; t[i]=t[i]+a[stp][edp]; if(edp==ed) break; else stp=edp; } } min=t[st];index=st; for(i=1;i<=p;i++) { if(min>t[i]) {

min=t[i]; index=i; } } printf("minimum cost %d",min); printf("\n minimum cost path "); for(i=1;i<=5;i++) { printf("--> %d",path[index][i]); if(path[index][i]==ed) break; } getch(); } INPUT: enter the cost matrix : 0 1 4 2 0 0 0 0 2 3 0 0 0 3 0 0 0 0 0 5 0 0 0 0 0 enter number of paths : 4 enter possible paths : 1 2 4 5 0 1 2 5 0 0 1 4 5 0 0 1 3 4 5 0 OUTPUT: minimum cost : 4 minimum cost path : 1-->2-->5

Ex. No : 4

DISTANCE VECTOR ROUTING ALGORITHM


AIM To write a program for implementation of distance vector routing algorithm. DESCRIPTION Routing algorithms are a part of the network layer software whose responsibility is to decide what destination output line should be selected for successful journey completion of the packet from the source machine to destination machine. The network layer of ISO-OSI reference model is responsible for getting packets from the source to the destination. It uses routing algorithms to effectively use all communication lines and routers present in the communication subnet and decide which lines to use for forwarding incoming packets.

Classification of Routing Algorithms


Routing algorithms are of classified on the basis of routing decisions made by them. They are either non adaptive or adaptive. Non adaptive algorithms do not change routing decisions on the basis of measurements of current traffic and topology, where as adaptive routing algorithms do change routing decisions on basis of measurements of current traffic and topology. Non adaptive algorithms are also called static algorithms and adaptive algorithms are also called dynamic algorithms.

Types of Routing Algorithms Shortest Path Routing


Shortest path routing is a static (non adaptive) routing algorithm. In this algorithm a graph of the communication subnet is created with each node representing a router and each edge representing a communication line (link). Finding the shortest path between two nodes is

done on the basis of some type of measurements. These measurements are called metrics. Some of the metrics used are number of hops, physical distance, mean queuing and transmission delays. Metrics like transmission delays and queue length are measured hourly for standard test packets sent out on each line of the communication subnet. Shortest path can be calculated on the basis of any one of the criteria or a combination of criteria. The most simple and widely used algorithm for finding the shortest path is the Dijkstras algorithm.

Distance Vector Routing


Most computer networks in operation today use dynamic routing algorithms rather than static routing algorithms. One of the widely used dynamic algorithms is Distance Vector routing, which is also known as Bellman Ford algorithm. A table maintained by a router is called a vector. Vectors contain information on how to get to the destination using the best possible path to get to it. It also contains an entry for each router in the subnet. Each of the routing tables is updated continuously. This can be done by exchanging information with the neighboring routers. For measuring the optimal distance between each node, metrics are used, similar to ones described above in the classification section of the article. The optimal path is followed till the packet reaches the destination machine. Distance vector algorithms use the Bellman-Ford algorithm. This approach assigns a number, the cost, to each of the links between each node in the network. Nodes will send information from point A to point B via the path that results in the lowest total cost (i.e. the sum of the costs of the links between the nodes used). The algorithm operates in a very simple manner. When a node first starts, it only knows of its immediate neighbours, and the direct cost involved in reaching them. (This information, the list of destinations, the total cost to each, and the next hop to send data to get there, makes up the routing table, or distance table.) Each node, on a regular basis, sends to each neighbour its own current idea of the total cost to get to all the destinations it knows of. The neighbouring node(s) examine this information, and compare it to what they already 'know'; anything which represents an improvement on what they already have, they insert in their own routing table(s). Over time, all the nodes in the network will discover the best next hop for all destinations, and the best total cost. When one of the nodes involved goes down, those nodes which used it as their next hop for certain destinations discard those entries, and create new routing-table information. They then pass this information to all adjacent nodes, which then repeat the process. Eventually all the nodes in the network receive the updated information, and will then discover new paths to all the destinations which they can still "reach". Ex. No: 08

RSA ENCRYPTION AND DECRYPTION


AIM To write a program for implementing RSA Algorithm for Encryption and Decryption DESCRIPTION RSA Algorithm The RSA algorithm is named after Ron Rivest, Adi Shamir and Len Adleman, who invented it in 1977 [RIVE78]. The basic technique was first discovered in 1973 by Clifford Cocks [COCK73] of CESG (part of the British GCHQ) but this was a secret until 1997 - see The History of IDPKC. The RSA algorithm can be used for both public key encryption and digital signatures. Its security is

based on the difficulty of factoring large integers. Key Generation Algorithm 1. Generate two large random primes, p and q, of approximately equal size such that their product n = pq is of the required bit length, e.g. 1024 bits. [See note 1]. 2. Compute n = pq and () phi = (p-1)(q-1). 3. Choose an integer e, 1 < e < phi, such that gcd(e, phi) = 1. [See note 2]. 4. Compute the secret exponent d, 1 < d < phi, such that ed 1 (mod phi). [See note 3]. 5. The public key is (n, e) and the private key is (n, d). The values of p, q, and phi should also be kept secret. n is known as the modulus. e is known as the public exponent or encryption exponent. d is known as the secret exponent or decryption exponent. Encryption Sender A does the following:1. Obtains the recipient B's public key (n, e). 2. Represents the plaintext message as a positive integer m [see note 4]. 3. Computes the ciphertext c = m^e mod n. 4. Sends the ciphertext c to B. Decryption Recipient B does the following:1. Uses his private key (n, d) to compute m = c ^d mod n. 2. Extracts the plaintext from the integer representative m. Digital signing Sender A does the following:1. Creates a message digest of the information to be sent. 2. Represents this digest as an integer m between 0 and n-1. [See note 5]. 3. Uses her private key (n, d) to compute the signature s = m ^d mod n. 4. Sends this signature s to the recipient, B. Signature verification Recipient B does the following:1. Uses sender A's public key (n, e) to compute integer v = s ^e mod n. 2. Extracts the message digest from this integer. 3. Independently computes the message digest of the information that has been signed. 4. If both message digests are identical, the signature is valid. Notes on practical applications 1. To generate the primes p and q, generate a random number of bit length b/2 where b is the required bit length of n; set the low bit (this ensures the number is odd) and set the two highest bits (this ensures that the high bit of n is also set); check if prime (use the RabinMiller test); if not, increment the number by two and check again. This is p. Repeat for q starting with an integer of length b-b/2. If p<q, swop p and q (this only matters if you intend using the CRT form of the private key). In the extremely unlikely event that p = q, check your random number generator. For greater security, instead of incrementing by 2, generate another random number each time. 2. In practice, common choices for e are 3, 17 and 65537 (2 ^16+1). These are Fermat primes and are chosen because they make the modular exponentiation operation faster. Also, having

chosen e, it is simpler to test whether gcd(e, p-1)=1 and gcd(e, q-1)=1 while generating and testing the primes in step 1. Values of p or q that fail this test can be rejected there and then. (Even better: if e is prime and greater than 2 then you can do the less-expensive test (p mod e)!=1 instead of gcd(p-1,e)==1.) 3. To compute the value for d, use the Extended Euclidean Algorithm to calculate d = e^-1 mod phi (this is known as modular inversion). 4. When representing the plaintext octets as the representative integer m, it is usual to add random padding characters to make the size of the integer m large and less susceptible to certain types of attack. If m = 0 or 1 there is no security as the ciphertext has the same value. For more details on how to represent the plaintext octets as a suitable representative integer m, see [PKCS1]. It is important to make sure that m < n otherwise the algorithm will fail. This is usually done by making sure the first octet of m is equal to 0x00. 5. Decryption and signing are identical as far as the mathematics is concerned as both use the private key. Similarly, encryption and verification both use the same mathematical operation with the public key. That is, mathematically, m = (m^e mod n)^d mod n = (m^d mod n)^e mod n, m < n However, note these important differences in implementation:o The signature is derived from a message digest of the original information. The recipient will need to follow exactly the same process to derive the message digest, using an identical set of data. o The recommended methods for deriving the representative integers are different for encryption and signing (encryption involves random padding, but signing uses the same padding each time). Summary of RSA n = pq where p and q are distinct primes. phi, = (p-1)(q-1) e < n such that gcd(e, phi)=1 d = e^-1 mod phi. c = m^e mod n, 1<m<n. m = c^d mod n. A very simple example of RSA encryption This is an extremely simple example using numbers you can work out on a pocket calculator (those of you over the age of 35 can probably even do it by hand on paper). 1. Select primes p=11, q=3. 2. n = pq = 11.3 = 33 phi = (p-1)(q-1) = 10.2 = 20 3. Choose e=3 Check gcd(e, p-1) = gcd(3, 10) = 1 (i.e. 3 and 10 have no common factors except 1), and check gcd(e, q-1) = gcd(3, 2) = 1 therefore gcd(e, phi) = gcd(e, (p-1)(q-1)) = gcd(3, 20) = 1 4. Compute d such that ed 1 (mod phi) i.e. compute d = e^-1 mod phi = 3^-1 mod 20 i.e. find a value for d such that phi divides (ed-1) i.e. find d such that 20 divides 3d-1. Simple testing (d = 1, 2, ...) gives d = 7 Check: ed-1 = 3.7 - 1 = 20, which is divisible by phi.

5. Public key = (n, e) = (33, 3) Private key = (n, d) = (33, 7). This is actually the smallest possible value for the modulus n for which the RSA algorithm works. Now say we want to encrypt the message m = 7, c = m^e mod n = 7^3 mod 33 = 343 mod 33 = 13. Hence the ciphertext c = 13. To check decryption we compute m' = c^d mod n = 13^7 mod 33 = 7. Note that we don't have to calculate the full value of 13 to the power 7 here. We can make use of the fact that a = bc mod n = (b mod n).(c mod n) mod n so we can break down a potentially large number into its components and combine the results of easier, smaller calculations to calculate the final value. One way of calculating m' is as follows:m' = 13^7 mod 33 = 13^(3+3+1) mod 33 = 13^3.13^3.13 mod 33 = (13^3 mod 33).(13^3 mod 33).(13 mod 33) mod 33 = (2197 mod 33).(2197 mod 33).(13 mod 33) mod 33 = 19.19.13 mod 33 = 4693 mod 33 = 7. Now if we calculate the ciphertext c for all the possible values of m (0 to 32), we get m 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 c 0 1 8 27 31 26 18 13 17 3 10 11 12 19 5 9 4 m 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 c 29 24 28 14 21 22 23 30 16 20 15 7 2 6 25 32 Note that all 33 values of m (0 to 32) map to a unique code c in the same range in a sort of random manner. In this case we have nine values of m that map to the same value of c - these are known as unconcealed messages. m = 0 and 1 will always do this for any N, no matter how large. But in practice, higher values shouldn't be a problem when we use large values for N. If we wanted to use this system to keep secrets, we could let A=2, B=3, ..., Z=27. (We specifically avoid 0 and 1 here for the reason given above). Thus the plaintext message "HELLOWORLD" would be represented by the set of integers m 1, m2, ... {9,6,13,13,16,24,16,19,13,5} Using our table above, we obtain ciphertext integers c 1, c2, ... {3,18,19,19,4,30,4,28,19,26} Note that this example is no more secure than using a simple Caesar substitution cipher, but it serves to illustrate a simple example of the mechanics of RSA encryption. Remember that calculating m^e mod n is easy, but calculating the inverse c ^-e mod n is very difficult, well, for large n's anyway. However, if we can factor n into its prime factors p and q, the solution

becomes easy again, even for large n's. Obviously, if we can get hold of the secret exponent d, the solution is easy, too.

You might also like