Hi sololearners, im trying to encrypt a sentence with ceaser cypher in c++ but I'm facing problem in this | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Hi sololearners, im trying to encrypt a sentence with ceaser cypher in c++ but I'm facing problem in this

string str; getline(cin,str) For(int i=0;(i<str.length()&&str[i]!='\0');i++) { str[i]='a'-str[i]+'z'; cout<<str; } this only encryping one string before space.

6th Jul 2020, 3:45 AM
Raju
Raju - avatar
1 Answer
+ 2
1) take cout<<str out of the loop. 2) handel the space also Here the fix👇 https://code.sololearn.com/ccRUC1X94iIc/?ref=app Also looks like you are using a static key = -1 to encipher the text. Generally in Ceaser cypher, we use randomly generated key or ask the key from the user to make the encryptions stronger.
6th Jul 2020, 4:15 AM
Arsenic
Arsenic - avatar