a C++ program to perform 128-bit encryption and decryption using XOR operation.

Write your question here.
Write a C++ program to perform 128-bit encryption and decryption using XOR operation.
Your program must ask for 128-bit key and plain text then perform encryption and decryption.
Write a C++ program to perform 128-bit encryption and decryption using XOR operation.
Your program must ask for 128-bit key and plain text then perform encryption and decryption.


You didn't write your c++ question! What part of this are you having trouble with? What have you done so far? Post your current code.
i got this in an assignment ,i haven't even started the code as i have no idea what to do in this question , any tip or hint would be great thanks
read in 128 bits. that is 16 bytes. ask for the key in hex (32 letters typed in) or some format you can easily mash into 16 bytes as an array. remember that they type in text, but you want to work with it as a numeric value.
then iterate. for all the letters in the string, letter^=key[index%16]. But, how do you decrypt it? what is the special property of xor ?

special note: ascii xor results are frequently going to be unprintable. Print in hex, or to a binary file, or something, but do not be astounded if you get an ascii zero or other goofball result. That is fine. Its really just numbers, and the numbers are valid and will decrypt correctly even if it is nonsense when encrypted. You can use the UUencode algorithm if you need to display the encrypted values on screen as an alternative to hex -- its a way to turn 1 byte of binary into 2 bytes of printable text.
Last edited on
Have you even read the book? The teacher shouldn't be giving you assignments without telling you how to do them. Have you learned 128-bit encryption, or even encryption at all? Have you learned how to use XOR?

If you really don't know how to do it, google "128 bit encryption c++" and that should give you something to start on.

Here're some rules to go by when posting here:
Rules & Regulations for posting on C++ forums

1: Try your best to solve your problem on your own before posting; no one appreciates people dumping their homework assignments without even trying to do them first.

2: Explain your problem or assignment very clearly (or just post the assignment itself).

3: Post whatever code you have already written, so we can see that you've actually made some effort on it, as well as any compiler errors, warnings, etc that you are having trouble with. This is linked to 1 above.

4: When you post your code, use code tags:

http://www.cplusplus.com/articles/jEywvCM9/
http://www.cplusplus.com/articles/z13hAqkS/


It makes your code easier to read, along with proper indenting (just copy and paste your code directly from your IDE to preserve formatting).

Rules&Regs, @agent max, from cplusplus.com

Thanks!
max
Last edited on
Do you know what xor is? Maybe we can start with that.
Topic archived. No new replies allowed.