Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Modify example 8-42 to encrypt the message using an algorithm of your own design

ID: 665855 • Letter: M

Question

Modify example 8-42 to encrypt the message using an algorithm of your own design.

Char EncryptionKey=0x45

Char Encrypt (char code)

{

     _asm

     {

           Mov AL,CODE

           XOR AL,EncryptionKey

           MOV CODE,AL

           INC AL

           AND AL,7fh

           MOV EncryptionKey,AL

     }

     RETURN CODE;

}

Private: System: :Void button1_Click(System: :Object^ sender,

     System: :EventArgs^ e)

{

     richTextBox1->Text = ;

     for(int a=0; a<textBox1->Text->Length; a++)

     {

richTextBox1->Text += Convert: :ToChar(Encrypt(textBox1->Text[a]));

     }

}

Explanation / Answer

Encryption is changed by performing XNOR operation instead of XOR and NAND instead of AND. This will lead to a new encrypted value.

Char EncryptionKey=0x45

Char Encrypt (char code)

{

     _asm

     {

           Mov AL,CODE

           XNOR AL,EncryptionKey

           MOV CODE,AL

           INC AL

           NAND AL,7fh

           MOV EncryptionKey,AL

     }

     RETURN CODE;

}

Private: System: :Void button1_Click(System: :Object^ sender,

     System: :EventArgs^ e)

{

     richTextBox1->Text = ;

     for(int a=0; a<textBox1->Text->Length; a++)

     {

richTextBox1->Text += Convert: :ToChar(Encrypt(textBox1->Text[a]));

     }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote