diff options
-rw-r--r-- | README | 17 | ||||
-rw-r--r-- | fromCBC.cpp | 62 | ||||
-rw-r--r-- | toCBC.cpp | 54 |
3 files changed, 133 insertions, 0 deletions
@@ -0,0 +1,17 @@ +# Kamil Kaminski +# NetID: kkamin8 +# +# CS340 +# Project 2, RSA Encryption +# + +Project can be compiled by issuing: +$ make + +For primality check, I used Miller Rabin algorithm from: +http://en.literateprograms.org/Miller-Rabin_primality_test_%28C%29 + +Notes on keygen: + - keygen's '-c' flag generates 16-bit prime numbers + - I added extra flags, '-p' and '-q', for prime p and prime q + diff --git a/fromCBC.cpp b/fromCBC.cpp new file mode 100644 index 0000000..fde531f --- /dev/null +++ b/fromCBC.cpp @@ -0,0 +1,62 @@ +// This program will take a "character-by-character" +// file and convert it to an ASCII text file +// The "character-by-character" file which will contain +// a single decimal value on each line where the decimal +// value corresponds to an ASCII charaster. +// +// Pat Troy, 2/7/2011 + +#include <fstream> +#include <iostream> +#include <cstdlib> + +using namespace std; + +int main (int argc, char *argv[]) +{ + ifstream infile; + ofstream outfile; + + char bit; + int charValue; + int i; + + //for (i = 0; i < argc; i++) + //cout << i << ": " << argv[i] << endl; + + if (argc < 2) + { + cout << "Usage: " << argv[0] << " inputFileName [ outputFileName ]" << endl; + exit(1); + } + + cout << argv[0] << ": opening file " << argv[1] << endl; + infile.open (argv[1]); + + if ( argc < 3 ) + { + outfile.open ("outfile.txt"); + } + else + outfile.open (argv[2]); + + i = 0; + while (!infile.eof()) + { + infile >> charValue; + if (infile.good()) + { + if ((charValue < 1) || (charValue > 127)) + cerr << "Value outside of ASCII range: " << charValue << endl; + else + outfile << (char)charValue; + } + i++; + } + + infile.close(); + outfile.close(); + + return 0; +} + diff --git a/toCBC.cpp b/toCBC.cpp new file mode 100644 index 0000000..f8af0fb --- /dev/null +++ b/toCBC.cpp @@ -0,0 +1,54 @@ +// This program will take an ASCII text file +// and covert the file to a "character-by-character" +// file which will contain the decimal value from +// each ASCII character. + +#include <fstream> +#include <iostream> +#include <cstdlib> + +using namespace std; + +int main (int argc, char *argv[]) +{ + ifstream infile; + ofstream outfile; + + char bit; + int charValue; + int i; + + //for (i = 0; i < argc; i++) + //cout << i << ": " << argv[i] << endl; + + if (argc < 2) + { + cout << "Usage: " << argv[0] << " inputFileName [ outputFileName ]" << endl; + exit(1); + } + + cout << argv[0] << ": opening file " << argv[1] << endl; + infile.open (argv[1]); + + if ( argc < 3 ) + { + outfile.open ("outfile.cbc"); + } + else + outfile.open (argv[2]); + + i = 0; + while (!infile.eof()) + { + charValue = infile.get(); + if (infile.good()) + outfile << charValue << endl; + i++; + } + + infile.close(); + outfile.close(); + + return 0; +} + |