Answer the question
In order to leave comments, you need to log in
How does the Caesar cipher work in "C"?
There is a task in the "C" language to develop an encryption program using the Caesar algorithm. The formula itself is here: ci = (pi + k) % 26
Actually, I could not apply this formula with respect to the application, I started looking for examples and came across the following options:
if(isupper(text[i])){
text[i] = (text[i] - 'A' + k) % 26;
text[i] = text[i] + 'A';
} else{
text[i] = (text[i] - 'a' + k) % 26;
text[i] = text[i] + 'a';
}
if(islower(text[i]))
{
printf("%c", ((((text[i] - 97)+k)%26)+97));
}
else
{
printf("%c", ((((text[i] - 65)+k)%26)+65));
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question