Class Server
java.lang.Object
|
+--Server
- public class Server
- extends java.lang.Object
This class is a simple server. Its port is set to 6502 on
the machine it is running on. It does not use threads but should.
This server reads a series of BigInteger objects from the client.
It is assumed that each BigInteger object was constructed on the client in the following
way:
1) A block of bytes was read from a file (or other location) on the
client's machine. This block of bytes was of size >= 1 and <= 10.
2) The number of bytes read was prepended to this block of bytes and an
array of bytes was formed. For example, suppose the bytes we read from the
input file were 65 66 67 ('A', 'B', and 'C' in ASCII). We would form the
array of bytes x formatted as follows:
x[0] = 3
x[1] = 65
x[2] = 66
x[3] = 67
3) The array of bytes was then converted to a BigInteger using Java's
BigInteger constructor that accepts an array of bytes as input.
4) The BigInteger plaintext was then enciphered using RSA with a public
key.
The server decodes each BigInteger object producing a decoded BigInteger. The
resulting BigInteger is converted to an array of bytes using Java's toByteArray()
method for BigIntegers. The first byte of this array specifies the number of bytes
that follow. The server writes out each of these bytes, excluding the first, so
that the file is the same as that found on the client's machine.
Please use this class to test your client. On a later date, you will be given
a public key and be asked to encrypt binary and ASCII files and send them to
a server on the internet.
Method Summary |
static void |
main(java.lang.String[] args)
|
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Server
public Server()
main
public static void main(java.lang.String[] args)
throws java.io.IOException