Caesar凯撒加密的解密

public string Decrypt(string word)
{
    word = word.ToLower();
    string decryptedWord = "";
    char[] split = word.ToCharArray();
    foreach (char character in split)
    {
        switch (character)
        {
            case 'a': decryptedWord += "x"; break;
            case 'b': decryptedWord += "y"; break;
            case 'c': decryptedWord += "z"; break;
            case 'd': decryptedWord += "a"; break;
            case 'e': decryptedWord += "b"; break;
            case 'f': decryptedWord += "c"; break;
            case 'g': decryptedWord += "d"; break;
            case 'h': decryptedWord += "e"; break;
            case 'i': decryptedWord += "f"; break;
            case 'j': decryptedWord += "g"; break;
            case 'k': decryptedWord += "h"; break;
            case 'l': decryptedWord += "i"; break;
            case 'm': decryptedWord += "j"; break;
            case 'n': decryptedWord += "k"; break;
            case 'o': decryptedWord += "l"; break;
            case 'p': decryptedWord += "m"; break;
            case 'q': decryptedWord += "n"; break;
            case 'r': decryptedWord += "o"; break;
            case 's': decryptedWord += "p"; break;
            case 't': decryptedWord += "q"; break;
            case 'u': decryptedWord += "r"; break;
            case 'v': decryptedWord += "s"; break;
            case 'w': decryptedWord += "t"; break;
            case 'x': decryptedWord += "u"; break;
            case 'y': decryptedWord += "v"; break;
            case 'z': decryptedWord += "w"; break;
        }
    }
    return decryptedWord;
}
posted @ 2013-05-02 09:48  乔先生  阅读(469)  评论(0编辑  收藏  举报