From dc1a4f16380c84e09084b6253e43ee303f1e8879 Mon Sep 17 00:00:00 2001 From: cdez Date: Mon, 4 Sep 2023 16:51:25 -0700 Subject: [PATCH] Getting Closer to fixing this +- EncryptionUtility.c +- PA01_Main --- PA01-0906/EncryptionUtility.c | 70 +++++++++++++++++++++++++--------- PA01-0906/PA01_Main | Bin 24656 -> 24656 bytes 2 files changed, 52 insertions(+), 18 deletions(-) diff --git a/PA01-0906/EncryptionUtility.c b/PA01-0906/EncryptionUtility.c index 8d5281a..c16aa9e 100644 --- a/PA01-0906/EncryptionUtility.c +++ b/PA01-0906/EncryptionUtility.c @@ -21,11 +21,11 @@ Dependencies: as needed */ SquareArrayType *clearArrayType( SquareArrayType *data ) { - int rowIndex; + int oneDimensionIndex; - for( rowIndex = 0; rowIndex < data->sideSize; rowIndex++ ) + for( oneDimensionIndex = 0; oneDimensionIndex < data->sideSize; oneDimensionIndex++ ) { - free( data->array[ rowIndex ] ); + free( data->array[ oneDimensionIndex ] ); } free( data->array ); @@ -50,7 +50,7 @@ Dependencies: as needed */ SquareArrayType *createArrayType( int sideSize ) { - int rowIndex, colIndex; + int oneDimensionIndex, twoDimensionIndex; SquareArrayType *newData; newData = (SquareArrayType *)malloc( sizeof( SquareArrayType ) ); @@ -59,13 +59,13 @@ SquareArrayType *createArrayType( int sideSize ) newData->array = (int **)malloc( sideSize * sizeof( int * ) ); - for( rowIndex = 0; rowIndex < sideSize; rowIndex++ ) + for( oneDimensionIndex = 0; oneDimensionIndex < sideSize; oneDimensionIndex++ ) { - newData->array[ rowIndex ] = (int *)malloc( sideSize * sizeof( int ) ); + newData->array[ oneDimensionIndex ] = (int *)malloc( sideSize * sizeof( int ) ); - for( colIndex = 0; colIndex < sideSize; colIndex++ ) + for( twoDimensionIndex = 0; twoDimensionIndex < sideSize; twoDimensionIndex++ ) { - newData->array[ rowIndex ][ colIndex ] = (int)ASTERISK; + newData->array[ oneDimensionIndex ][ twoDimensionIndex ] = (int)ASTERISK; } } @@ -175,33 +175,67 @@ SquareArrayType *encryptData( const char *toEncrypt ) // iterate through the array (backwards?) [Past Charles, see diagram that you made of Square Array] int oneDimensionIndex; int twoDimensionIndex; + int differenceIndex; int currentCharacter = 0; int flagEndString = 0; - for(oneDimensionIndex = stringLenRoot - 1; oneDimensionIndex >= 0; oneDimensionIndex--) + // for(oneDimensionIndex = stringLenRoot - 1; oneDimensionIndex >= 0; oneDimensionIndex--) + // { + // // one dimension to move through array + // for(twoDimensionIndex = stringLenRoot - 1; twoDimensionIndex >= 0; twoDimensionIndex--) + // { + // if(flagEndString == 1) + // { + // // check the flag, if it is set, then start putting random data into rest of the array. + // encryptedData->array[oneDimensionIndex][twoDimensionIndex] = getRandomLetterValue(); + // } + // // second dimension to move through array + // if(toEncrypt[currentCharacter] == NULL_CHAR) + // { + // // if the null character is there, replace with the Unprintable, set flag to one. + // encryptedData->array[oneDimensionIndex][twoDimensionIndex] = UNPRINTABLE_CHAR_VALUE; + // flagEndString = 1; + // } + // else + // { + // // otherwise, continue putting the data into the 2d array. + // encryptedData->array[oneDimensionIndex][twoDimensionIndex] = toEncrypt[currentCharacter]; + // } + // currentCharacter = currentCharacter + 1; + // } + // } +for(oneDimensionIndex = stringLenRoot * 2; oneDimensionIndex >= 0; oneDimensionIndex--) +{ + // + for(twoDimensionIndex = oneDimensionIndex; twoDimensionIndex >= 0; twoDimensionIndex--) { - // one dimension to move through array - for(twoDimensionIndex = stringLenRoot - 1; twoDimensionIndex >= 0; twoDimensionIndex--) + // + differenceIndex = oneDimensionIndex - twoDimensionIndex; + if(differenceIndex < stringLenRoot && twoDimensionIndex < stringLenRoot) { - if(flagEndString == 1) - { - // check the flag, if it is set, then start putting random data into rest of the array. - encryptedData->array[oneDimensionIndex][twoDimensionIndex] = getRandomLetterValue(); - } + // printf("C "); // second dimension to move through array if(toEncrypt[currentCharacter] == NULL_CHAR) { // if the null character is there, replace with the Unprintable, set flag to one. - encryptedData->array[oneDimensionIndex][twoDimensionIndex] = UNPRINTABLE_CHAR_VALUE; + encryptedData->array[twoDimensionIndex][differenceIndex] = UNPRINTABLE_CHAR_VALUE; + currentCharacter = currentCharacter + 1; flagEndString = 1; } else { // otherwise, continue putting the data into the 2d array. - encryptedData->array[oneDimensionIndex][twoDimensionIndex] = toEncrypt[currentCharacter]; + encryptedData->array[twoDimensionIndex][differenceIndex] = toEncrypt[currentCharacter]; + } + if(flagEndString == 1) + { + // check the flag, if it is set, then start putting random data into rest of the array. + encryptedData->array[twoDimensionIndex][differenceIndex] = getRandomLetterValue(); } currentCharacter = currentCharacter + 1; } } + //printf("\n"); +} // once null character is reached, put the 'unprintable character' then random data afterward. // returns a Square Array. return encryptedData; diff --git a/PA01-0906/PA01_Main b/PA01-0906/PA01_Main index 286b1005fff1b1ad6175bce1d59d609867121c56..70ca7c01756fab69b2512958ddebba3e261687ff 100755 GIT binary patch delta 3408 zcmZ{mdr(tX9>?#wfP$hS_y{QpmjH=8LPC6?fLg6wxIF5vR$SfMmA2O6hz}}u?T#*1 z)G-Zg3%~8m)?I6zc74oJM?_g2I|b27Z8J6~-8$8^Y^53{u7J2wMYG?VTqQWu{PFvo z^Lw4w@0?s$GjlbwL!m5ehQRrLGaA(Fb$;v*DQ8>1%3YQp{A^Xjy{X1awfi0%YN!fw zMyNZ&IZmqH*8RxqmF%tVu%Lz&V^#c^m91i@oSVS z$dE)IQ@SR-LXzy8j!6#jm^|SOp5yG|WruhfoovQ&y{d>&Z)jyMI@zl-H`~Pyhu8t* zClBQ%itbjiU7lpCcu@vy3_i{qeZG#hvPVQ%&yhuAK?3J*-4xm1nZ*5>sS ze=!9OXrkv2@eln)Uu8JfqWb)#ov#$zS>-AhtK8(`RQ71E*IT*DiJlWZo_0pf;73G} zMXROWs7!X0Qnho~TU4f9#$WEI@3eaMDc#jh)r9nWy>_v`RUE)_xvua^ae%qI@6nuR z2Ke6p(d_7A-gTEgj^4obl1`U3Zs%CJmZrQf!`|v&wuwr0u`GnDbxGq!-t~IVp1Pxo zxnCsNe`*?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