knapsack.java
/** main method to test and utilize all methods defined in this
	*   document.
	*   @param args arguments.
	*/
main method to test and utilize all methods defined in this
document.
@param args arguments.
main method to test and utilize all methods defined in this document . @param args arguments .
public static void main(String[] args) {
		BigInteger[] privateS = {new BigInteger("2"),new BigInteger("4"),
		new BigInteger("8"),new BigInteger("16"),new BigInteger("32"),
		new BigInteger("64"), new BigInteger("128"), new BigInteger("256")};
		BigInteger modulus = new BigInteger("1000");
		BigInteger multiplier = new BigInteger("333");
		BigInteger inverse = new BigInteger("997");
		byte[][] message = split("message.txt",1);
		BigInteger[] publicS = new BigInteger[privateS.length];
		publicS = publicSequence(privateS, modulus, multiplier);
		BigInteger[] encrypted = new BigInteger[message.length];
		for(int i = 0; i< message.length; i++) {
			encrypted[i] = encrypt(message[i],publicS);
		}
		int[][] decrypted = new int[message.length][];
		for(int i = 0; i< encrypted.length; i++) {
			decrypted[i] = decrypt(encrypted[i],privateS, inverse,modulus);
		}
		try {
			FileOutputStream fw = new FileOutputStream("encrypted.txt");
			for(int i = 0; i<encrypted.length; i++) {
				fw.write(encrypted[i].intValue());
			}
			fw.close();
		} catch (Exception e) {
			System.err.println(e.getMessage());
		}
		try {
			FileOutputStream fw = new FileOutputStream("output.txt");
			for(int i = 0; i< decrypted.length; i++) {
				for(int j = 0; j<decrypted[i].length; j++) {
					fw.write(decrypted[i][j]);
				}
			}
			fw.close();
		} catch (Exception e) {
			System.err.println(e.getMessage());
		}
	}
public static void main ( String [ ] args ) { BigInteger [ ] privateS = { new BigInteger ( "2" ) , new BigInteger ( "4" ) , new BigInteger ( "8" ) , new BigInteger ( "16" ) , new BigInteger ( "32" ) , new BigInteger ( "64" ) , new BigInteger ( "128" ) , new BigInteger ( "256" ) } ; BigInteger modulus = new BigInteger ( "1000" ) ; BigInteger multiplier = new BigInteger ( "333" ) ; BigInteger inverse = new BigInteger ( "997" ) ; byte [ ] [ ] message = split ( "message.txt" , 1 ) ; BigInteger [ ] publicS = new BigInteger [ privateS . length ] ; publicS = publicSequence ( privateS , modulus , multiplier ) ; BigInteger [ ] encrypted = new BigInteger [ message . length ] ; for ( int i = 0 ; i < message . length ; i ++ ) { encrypted [ i ] = encrypt ( message [ i ] , publicS ) ; } int [ ] [ ] decrypted = new int [ message . length ] [ ] ; for ( int i = 0 ; i < encrypted . length ; i ++ ) { decrypted [ i ] = decrypt ( encrypted [ i ] , privateS , inverse , modulus ) ; } try { FileOutputStream fw = new FileOutputStream ( "encrypted.txt" ) ; for ( int i = 0 ; i < encrypted . length ; i ++ ) { fw . write ( encrypted [ i ] . intValue ( ) ) ; } fw . close ( ) ; } catch ( Exception e ) { System . err . println ( e . getMessage ( ) ) ; } try { FileOutputStream fw = new FileOutputStream ( "output.txt" ) ; for ( int i = 0 ; i < decrypted . length ; i ++ ) { for ( int j = 0 ; j < decrypted [ i ] . length ; j ++ ) { fw . write ( decrypted [ i ] [ j ] ) ; } } fw . close ( ) ; } catch ( Exception e ) { System . err . println ( e . getMessage ( ) ) ; } }
main method to test and utilize all methods defined in this
   document.
main method to test and utilize all methods defined in this document .
// split the message up into blocks of appropriate size
 // create the public sequence based on the parameters above
 // create the encrypted array
 // go through the message, and encrypt each block
 // this can be parallelized eventually
 // create the decrypted array, and go through the
 // encrypted sequence and decrypt each block of the
 // message, this can be parallelized eventually
 // try to write the decrypted message to a file
