Need Help Decoding C++ - Sajha Mobile
SAJHA MOBILE
Need Help Decoding C++
Posts 8 · Viewed 7157 · Go to Last Post
Sparty
· Snapshot 178
Like · Likedby · 0
I don't know if this will help you in your assignment. I can't write in C++, but here is the algorithm that I would use to write in my choice of language.
1. declare a string with alphabets, s = "abcd....z"
2. read the characters in your code one by one and count them
3. The most frequently used letter is 'e' (roughly 12%)
4. based on that I would find the rotation of the character in your code. By rotation I mean find the index of your character in the string 's' and subtract index of e, in this case it is 4.
5. Now shift each of your characters by that rotation, but leave the punctuations and blank spaces as they are.
6. After decoding see if it makes sense.

This might not work in your code, but you can give it a try.
Hope that helps
Sparty
· Snapshot 184
Like · Liked by · 0
By the way using the language that I use, I could partially decode it. Here is the decoded part if that helps

this is a sample input file for cosc 587:
assignment '542 ]our program should encode this
file b} adding four to the ascii value of each
character in it2 in }our encoded file the first character should
be +\+2 the last character of the first line should be +>+2
the encoded file should have < lines of te|t just like this one0
but {ill be unreadable2 the last character of the last line {ill
be a +6+2

I think the algorithm that I mentioned earlier needs some refinement, but you got the point that I was trying to convey. Good luck with your assignment
prankster
· Snapshot 186
Like · Liked by · 0
4 is the key?
djblade
· Snapshot 203
Like · Liked by · 0
I have the encrypted file in code.txt which is in same directory as source.cpp file. My code is supposed to ifstream encoded file and subtract 4 form ASCII value of each character. The output of the decoded file will in turn be stored in same directory as file plain2.txt

prankster
· Snapshot 195
Like · Liked by · 0
you do the reading from file part, I just assigned input the variable,
#include

using namespace std;

int main()
{
char c[] = "Xlmw$mw$e$weqtpi$mrtyx$jmpi$jsv$GSWG$587:ewwmkrqirx$\'542$]syv$tvskveq$wlsyph$irgshi$xlmwjmpi$f}$ehhmrk$jsyv$xs$xli$EwGMM$zepyi$sj$iegl$glevegxiv$mr$mx2$Mr$}syv$irgshih$jmpi$xli$jmvwx$glevegxiv$wlsyph$fi$+\+2$Xli$pewx$glevegxiv$sj$xli$jmvwx$pmri$wlsyph$fi$+>+2Xli$irgshih$jmpi$wlsyph$lezi$<$pmriw$sj$xi|x$nywx$pmoi$xlmw$sri0fyx${mpp$fi$yrviehefpi2$Xli$pewx$glevegxiv$sj$xli$pewx$pmri${mpp$fi$e$+6+2";
for (int i = 0; i< sizeof c; i ++)
{
char decodedString = c[i] - 4;
cout << decodedString;
}

return 0;
}

The output was:
This is a sample input file for
#10. Your program should encode
our to the AsCII value of each c
our encoded file the first chara
he last character of the first l
e encoded file should have 8 lin
prankster
· Snapshot 212
Like · Liked by · 0
If you want to learn file handling in c++,
http://www.tutorialspoint.com/cplusplus/cpp_files_streams.htm
prankster
· Snapshot 213
Like · Liked by · 0
Seems the output got truncated, here is the correct output,
This is a sample input file for COSC 1436assignment #10. Your program should encode thisfile by adding four to the AsCII value of each character in it. In your encoded file the first character should be '. The last character of the first line should be ':'.The encoded file should have 8 lines of text just like this one,but will be unreadable. The last character of the last line will be a '2'.�

djblade
· Snapshot 256
Like · Liked by · 0
Prankster bro, hands down you are the best. Genius
Please log in to reply to this post

You can also log in using your Facebook
View in Desktop
What people are reading
You might like these other discussions...
· Posts 1 · Viewed 61
· Posts 1 · Viewed 66
· Posts 15 · Viewed 3223 · Likes 3
· Posts 4 · Viewed 364
· Posts 1 · Viewed 307
· Posts 7 · Viewed 1755
· Posts 4 · Viewed 518 · Likes 1
· Posts 1 · Viewed 154
· Posts 1 · Viewed 155
· Posts 5 · Viewed 680



Your Banner Here
Travel Partners
Travel House Nepal