Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE HELP WRITE THE CODE IN C LANGUAGE . THANKS. please comment Intro to C- Lab Assignment 2 File Encryption The XOR operator is something

PLEASE HELP WRITE THE CODE IN C LANGUAGE. THANKS. please comment

image text in transcribedimage text in transcribed

Intro to C- Lab Assignment 2 File Encryption The XOR operator is something we had not yet introduced in class. It works on the bits that make up the binary representation of a variable, rather than the value of the variable. For example, each char is 1 byte, or 8 bits. XOR looks at the corresponding bits in each value and creates a new value. If the two bits in the values were different, the output will have a 1 in that position. If the two were the same the output has a 0 in that position. USING EXCLUSIVE OR (XOR) IN CRYPTOGRAPHY XOR LOGIC 0 XOR 0=0 Same Bits 1 XOR 1 0 Same Bits 1 XOR 0=1 Different Bits 0 XOR 1=1 Different Bits OR Symbol ENCRYPT 0011010 1 Plaintext 11100011 secret Key 11010110 ciphertext DECRYPT 11010110 ciphertext 11100011 secret key 00110 10 1 Plaintext What makes XOR useful for basic encryption is that the operation is reversible. By using XOR again with the key and the encrypted data, we get the original as output. While this is very easy to implement, keep in mind that this is not very secure The XOR operator in C is used with the caret symbol Use it like you would a plus sign, with one operator on each side of it. It only works on ints and chars. Your program must Ask the user for the name of the file to encrypt/decrypt Ask the user for the name of the file to save the encrypted/decrypted file to . Ask the user for the key to use Encrypt/Decrypt the file by reading it one character at a time, using XOR on that character with the next character in the key, and then writing that to the output file o For example, if the key was "hello", the first character is XOR'd with 'h', the second with 'e', and so on, with the key repeating, so the 6th will also be XOR'd with 'h o You will need to use the binary file modes

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

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions

Question

2. What do you believe is at the root of the problem?

Answered: 1 week ago