Question
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!
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 #includeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started