~ ASSEMBLY LANGUAGE USING NASM ~ -----------------------------------------------
ID: 3813642 • Letter: #
Question
~ ASSEMBLY LANGUAGE USING NASM ~
------------------------------------------------------------------------------------
The Vigenère cipher, invented in 1553, uses multiple Caesar ciphers so that the
frequency distribution of encoded letters is spread over several different encodings.
Some versions were based on something like sliding tables or concentric letter
wheels. However for military use in the field it is better not to need special
equipment and to have the cipher be based on something easy to remember such as
a keyword.
For better frequency characteristics the keyword should not have any repeated
letters. Also, if it contains the letter A the encrypted letter will be the same as the
plaintext, although this is not necessarily a bad thing.
To implement this algorithm with a pencil and paper, many descriptions ask you to
build a Vigenère Square. However this is not really necessary when you are using a
computer to do the encoding and decoding.
Essentially the keyword is written repeatedly over and over above the plaintext.
Suppose the keyword is CRYPTOGRAM.
CRYPTOGRAMCRYPTOGRAMCRYPTOGRAMCRYPTOGRAMCRYPTOGRAMCRYPTOGRAMCRYPTOGR
WEHAVEBEENBETRAYEDALLISDISCOVEREDFLYATONCEMEETUSBYTHEOLDTREEATNINEPM
Consider that the letters are numbered 0 to 25. The letter on the top determines
which Caesar-cypher to use for the letter below. Thus C means shift the alphabet by
2, A means shift by 0, and so on. In mathematical terms, we are adding the two
letters together modulo 26. (The square was used because the concept of modular
arithmetic was not generally understood by soldiers in 1553.)
To decrypt the message, the same operation is performed in reverse. That is, the
value of the keyword letter is subtracted rather than added.
Another example (Andrew Pennycook, Codes and Ciphers, MacKay, New York, 1980):
Key: SUFFERINGCATSSUFFERINGCA
Plaintext: BETHEREATMIDNIGHTTONIGHT
Ciphertext: TYYMIIMNZOIWFAAMYXFVVMST
Notice that the word "night" appears twice in the message. The first time it is
encoded as FAAMY and the second time as VVMJT. There is nothing to show that
they came from the same word in the original.
---------------------------------------------------------------------------------------
~~~ What your code should do ~~~~~
1. Your code should use STDIN and STDOUT for input and output. (This is the
default.) Use redirection on the command line to read from a file and write to a
file.
2. Your code should open a file, read it character by character and save it into an
array. Use C I/O functions.
3. When you get to the end of the file you should encode the contents of the
array with a Vigenère cipher using the keyword CRYPTOGRAM, then print it
out.
4. Maintain the distinction between upper-case and lower-case letters, and do
not modify non-alphabetic characters. This is not very good for the security of
your message, but the result will look neater.
5. This program should use glibc functions. In addition to printf(), you may
need getchar() and putchar().
6. Assume that the input file contains just ASCII text Don't worry about what
happens with non-text files.
Explanation / Answer
import java.util.ArrayList;
import java.util.List;
public category Cluster purpose centroid;
public int id;
//Creates a replacement Cluster
public Cluster(int id)
public List getPoints() come points;
}
public void addPoint(Point point)
public void setPoints(List points)
public purpose getCentroid() come centroid;
}
public void setCentroid(Point centroid);
}
public int getId()
public void clear()
public void plotCluster()
System.out.println("]");
}
}
Point.java
package com.dataonfocus.clustering;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public category purpose non-public double x = 0;
personal double y = 0;
personal int cluster_number = 0;
public Point(double x, double y)
public void setX(double x)
public double getX() come back this.x;
}
public void setY(double y)
public double getY() come back this.y;
}
public void setCluster(int n)
public int getCluster() come back this.cluster_number;
}
//Calculates the space between 2 points.
protected static double distance(Point p, purpose centroid) come back science.sqrt(Math.pow((centroid.getY() - p.getY()), 2) + Math.pow((centroid.getX() - p.getX()), 2));
}
//Creates random purpose
protected static purpose createRandomPoint(int min, int max) come back new Point(x,y);
}
protected static List createRandomPoints(int min, int max, int number)
come points;
}
public String toString() come "("+x+","+y+")";
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package com.dataonfocus.clustering;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public category purpose {
personal double x = 0;
personal double y = 0;
personal int cluster_number = 0;
public Point(double x, double y)
public void setX(double x)
public double getX() come back this.x;
}
public void setY(double y)
public double getY() come back this.y;
}
public void setCluster(int n)
public int getCluster() come back this.cluster_number;
}
//Calculates the space between 2 points.
protected static double distance(Point p, purpose centroid) come back science.sqrt(Math.pow((centroid.getY() - p.getY()), 2) + Math.pow((centroid.getX() - p.getX()), 2));
}
//Creates random purpose
protected static purpose createRandomPoint(int min, int max) come back new Point(x,y);
}
protected static List createRandomPoints(int min, int max, int number)
come points;
}
public String toString() come "("+x+","+y+")";
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.