Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with the - void DisplayCipherText(const String& text) and the -void EncryptString(String& text, const uint8_t keyByte[], size_t numKeyBytes) functions! Here is my program! Thanks!

image text in transcribed

Need help with the - void DisplayCipherText(const String& text) and the -void EncryptString(String& text, const uint8_t keyByte[], size_t numKeyBytes) functions! Here is my program! Thanks!

#include // Arduino standard library.

#include // Console utility library.

// This program accepts a line of plain text from the console, encrypts each character

// using a multi-byte encryption key applied via a bitwise XOR operation. After

// displaying the encrypted cipher text, the cipher text is then encrypted again using

// the same key, which should yield the original text back again.

// Bytes to use as the encryption key.

const uint8_t KeyBytes[] = { 0b00101010, 0b00111011, 0b10101110, 0b00111100 };

const size_t NumKeyBytes = sizeof(KeyBytes) / sizeof(KeyBytes[0]);

// *** Called once at program start up ***

void setup()

{

ConsoleSetup();

}

// *** Called repeatedly until a "reset" is performed ***

void loop()

{

DisplayNewline();

DisplayString("Encryption key bytes:");

DisplayNewline();

for ( size_t pos = 0; pos

{

DisplayString("Key[");

DisplayInteger(pos);

DisplayString("] = ");

DisplayAsBinary(KeyBytes[pos]);

DisplayNewline();

}

DisplayNewline();

DisplayString("Enter message text to encrypt:");

DisplayNewline();

// Get a line of input from the keyboard.

// Does NOT contain any end-of-line designator.

String plainText = KeyboardGetline();

DisplayNewline();

DisplayString("Message text is: ");

DisplayNewline();

DisplayCipherText(plainText);

// Encrypt the plain text using the key.

String cipherText(plainText);

EncryptString(cipherText, KeyBytes, NumKeyBytes);

DisplayNewline();

DisplayNewline();

DisplayString("Cipher text is: ");

DisplayNewline();

DisplayCipherText(cipherText);

// Encrypt the cipher text using the same key.

EncryptString(cipherText, KeyBytes, NumKeyBytes);

DisplayNewline();

DisplayNewline();

DisplayString("Encrypted cipher text is: ");

DisplayNewline();

DisplayCipherText(cipherText);

}

// ---------------------------------------------------------

// Routine to display the passed cipher text, character by character,

// one per line. If a character is printable, display the ASCII

// character inside single quote marks ('...'), otherwise display '?'.

// Then follow with the binary representation of the character.

void DisplayCipherText(const String& text)

{

}

// ---------------------------------------------------------

// Routine to encrypt the text string passed in using the

// specified 8-bit key byte array. The key bytes are applied

// in round-robin fashion to each byte of the text string.

void EncryptString(String& text, const uint8_t keyByte[], size_t numKeyBytes)

{

}

CSCI_Console.h #ifndef INCLUDE_CSCI_CONSOLE_H #define INCLUDE_CSCI_CONSOLE_H #include // Contains String object and other definitions Il Prototypes for console display and keyboard utilities void ConsoleSetup(); // Initialize the console; void DisplayInteger(int value); // Display default integer. void DisplayInteger(uint8_t value); 1/ Display 8-bit unsigned integer. void DisplayInteger(uint16_t value); // Display 16-bit unsigned integer. void Display Integer(int32_t value); // Display 32-bit integer. void DisplayInteger(uint32_t value); // Display 32-bit unsigned integer. void DisplayDouble( double value, size_t numDecimals); // Display floating point. void DisplayAsBinary(char value); // Display char as binary. void DisplayAsBinary(uint8_t value); // Display unsigned byte as binary. void DisplayAsBinary(uint16_t value); // Display unsigned integer as binary. void DisplayError(const String& errmsg); // Display error message, then pause. void DisplayPause(); // Display pause message, then wait. void DisplayString(const String& str); // Display string on the console. void DisplayNewline(); 1/ Advance display to next line. String KeyboardGetline(); // Get a line of input from the keyboard. #endif II INCLUDE_CSCI_CONSOLE_H

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual C# And Databases

Authors: Philip Conrod, Lou Tylee

16th Edition

1951077083, 978-1951077082

More Books

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago