Class Encoder

java.lang.Object
  |
  +--Encoder

public class Encoder
extends java.lang.Object

This class takes an array of bytes as plan text and encodes it.


Constructor Summary
Encoder(java.math.BigInteger e, java.math.BigInteger n)
          Constructs a new Encoder
 
Method Summary
 java.math.BigInteger encode(byte[] clear, int k)
          This takes an array of bytes that are the clear text, encodes it, and returns the bytes as an encoded BigInteger
static void main(java.lang.String[] args)
          Tests the Encoder class
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Encoder

public Encoder(java.math.BigInteger e,
               java.math.BigInteger n)
Constructs a new Encoder
Parameters:
e, - n These contain values for the encoding exponent and the modulus
Postcondition
A new Encoder has been created that contains the passed values.
Throws:
OutOfMemoryError - Indicates that there is insufficient memory for a new Encoder.
Method Detail

encode

public java.math.BigInteger encode(byte[] clear,
                                   int k)
This takes an array of bytes that are the clear text, encodes it, and returns the bytes as an encoded BigInteger
Parameters:
clear, - k These are an array of bytes representing the clear text of the message and an integer that represents the number of bytes that are in the array.
Precondition
The length of the array clear is greater than or equal to the int k
Postcondition
k bytes, representing the values found from byte[0] - byte[k-1] are encoded as a BigInteger
Returns:
Returns a BigInteger which represents the encoded data

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Tests the Encoder class
Parameters:
args[] - This parameter will be left empty
Postcondition
The BigInteger that represents the encoded value will be printed.
Throws:
OutOfMemoryError - Indicates that there is insufficient memory for a new Encoder, KeyGen, or array of bytes.