Rotational Cipher

in ita •  2 months ago 

using System;

public static class RotationalCipher
{
public static string Rotate(string text, int shiftKey){
string letterN = "";
shiftKey %= 26;
foreach(char i in text){
if(char.IsUpper(i)){
char res = (char) ('A' + (i - 'A' + shiftKey) % 26);
letterN += res;
}
else if (Char.IsLower(i)){
char res = (char) ('a' + (i - 'a' + shiftKey) % 26);
letterN += res;
}

        else {
            letterN += i;
        }
    }
    return letterN;
}

}

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!