Uploading Changes
+- EncryptionUtility.c +- PA01_Main
This commit is contained in:
parent
40e0bfd79a
commit
4b87557bcf
3 changed files with 55 additions and 26 deletions
|
|
@ -101,6 +101,35 @@ Notes: Does not handle empty square data type condition
|
|||
*/
|
||||
void displayArray( const SquareArrayType data, ControlCode ctrlCode )
|
||||
{
|
||||
int arraySize = data.sideSize;
|
||||
int oneDimensionIndex = 0, twoDimensionIndex = 0;
|
||||
// check the control code, branch to the respective path.
|
||||
// iterate through the array, one character at a time.
|
||||
// get the side size from the array, iterate that number of times, then output a new line.
|
||||
if(ctrlCode == DISPLAY_CHARS)
|
||||
{
|
||||
for(oneDimensionIndex = 0; oneDimensionIndex < arraySize; oneDimensionIndex++)
|
||||
{
|
||||
for(twoDimensionIndex = 0; twoDimensionIndex < arraySize; twoDimensionIndex++)
|
||||
{
|
||||
printCharacter((char)data.array[oneDimensionIndex][twoDimensionIndex]);
|
||||
printCharacter(SPACE);
|
||||
}
|
||||
printEndline();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(oneDimensionIndex = 0; oneDimensionIndex < arraySize; oneDimensionIndex++)
|
||||
{
|
||||
for(twoDimensionIndex = 0; twoDimensionIndex < arraySize; twoDimensionIndex++)
|
||||
{
|
||||
printInteger((int)data.array[oneDimensionIndex][twoDimensionIndex]);
|
||||
printCharacter(SPACE);
|
||||
}
|
||||
printEndline();
|
||||
}
|
||||
}
|
||||
// no return.
|
||||
}
|
||||
/*
|
||||
|
|
@ -148,33 +177,34 @@ SquareArrayType *encryptData( const char *toEncrypt )
|
|||
int twoDimensionIndex;
|
||||
int currentCharacter = 0;
|
||||
int flagEndString = 0;
|
||||
for(oneDimensionIndex = stringLenRoot; oneDimensionIndex >= 0; oneDimensionIndex--)
|
||||
for(oneDimensionIndex = stringLenRoot - 1; oneDimensionIndex >= 0; oneDimensionIndex--)
|
||||
{
|
||||
// one dimension to move through array
|
||||
for(twoDimensionIndex = stringLenRoot; twoDimensionIndex >= 0; twoDimensionIndex--)
|
||||
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[oneDimensionIndex][twoDimensionIndex] = UNPRINTABLE_CHAR_VALUE;
|
||||
encryptedData->array[oneDimensionIndex][twoDimensionIndex] = UNPRINTABLE_CHAR_VALUE;
|
||||
flagEndString = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// otherwise, continue putting the data into the 2d array.
|
||||
encryptedData[oneDimensionIndex][twoDimensionIndex] = toEncrypt[currentCharacter];
|
||||
}
|
||||
if(flagEndString == 1)
|
||||
{
|
||||
// check the flag, if it is set, then start putting random data into rest of the array.
|
||||
encryptedData[oneDimensionIndex][twoDimensionIndex] = getRandomLetterValue();
|
||||
encryptedData->array[oneDimensionIndex][twoDimensionIndex] = toEncrypt[currentCharacter];
|
||||
}
|
||||
currentCharacter = currentCharacter + 1;
|
||||
}
|
||||
}
|
||||
// once null character is reached, put the 'unprintable character' then random data afterward.
|
||||
// returns a Square Array.
|
||||
return NULL;
|
||||
return encryptedData;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue