For anyone stopping by, I needed to make all of the "char" variables unsigned. "unsigned char num, num2, num3;"
Hello. I've searched here and around the internet for an answer and I've found many different variations of a solution to my problem, but my professor said I shouldn't need a template, asm, etc.
I have a file I need to decrypt. The first half was single encrypted and gave me instructions for the next part.
The following text is encrypted using the binary shift to the left. Look up the binary shift operator, and you should be able to figure out what is the operator for a left binary shift as well as how to undo a left binary shift. Good luck!
The 2nd half's 2nd line of encryption is a single circular shift to the left. So I need to shift every char to the right once and have it wrap.
I've seen people use things we haven't learned yet, like templates and something about _asm and x86 and #define and other things.
I found a post on stockoverflow that made sense to me and I tried to replicate it: http://stackoverflow.com/a/776797
Any ideas? Is the ONLY way to do this with a template or something?
tl:dr I need help with circular binary shift in C++ and I've searched everywhere.
Use unsigned char, not char. If you shift, say, 11100000 four bits to the right, you want to get back 00001110, but with char (char is usually signed), you'll get 11111110.
I tried that earlier, but my mistake was:
char num, num2;
unsigned char num3;
I didn't try it on all of the var's because I was worried it would mess up the "num ^ 88" operation. Thank you for telling me to do it again. I was smart enough this time to try it on all of them. Now I realize how silly my thought process was earlier.
I just had a great, "Wow I'm dumb", moment. I love those! Means you learned something and can laugh about it.