getColumn - int null = 0; #define MAX_KEY_LENGTH 50 int...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Lecture: Lab 3 - getColumn 1 How to convert a one-dimentional array into a two-dimentional array? Char plain[MAX_PLAIN]; Char newPlain[MAX_ROW][MAX_COL]; max_row = ceil(plain.length / key.length); for (i = 0; i < max_row*key.length; i++) { j = i/key.length; k = i%key.length; if (i < plain.length) newplain[j][k] = plain[i]; else newplain[j] = ‘*’; } How to create (encrypt) a transpotion cipher? i = 0; max_row = ceil(plain.length / key.length); for (k = 0; k < key.length; k++) { colID = getClumn(key, key.length); for (j = 0; j < max_row; j++) cipher[i] = newplain[j][colID]; } #include <iostream> #include <limits.h> using namespace std; //#define DEL 255; const
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: int null = 0; #define MAX_KEY_LENGTH 50 int getColumn( char key, int keylength); //Can you write a test driver for getColumn? main() { char testkey[MAX_KEY_LENGTH] = "application" ; int index; for (index = 0; index < 11; index++) cout << "keyOrder[" << index << "] = " << getColumn(testkey, 11) << endl; return 0; } //Return the index of the letter with the minimum ASCII int getColumn( char key, int keylength) { int minIndex = -1; int minASCII = INT_MAX; int i; for (i = 0; i < keylength; i++) { Lecture: Lab 3 - getColumn 2 if (key[i] != null && key[i] < minASCII) { minIndex = i; minASCII = key[i]; } } key[minIndex] = null; return minIndex; }...
View Full Document

This note was uploaded on 12/07/2011 for the course COMP 2710 taught by Professor Staff during the Fall '08 term at Auburn University.

Page1 / 2

getColumn - int null = 0; #define MAX_KEY_LENGTH 50 int...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online