宁可辛苦一阵子,不要辛苦一辈子

VocanoLee学习手札

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
using System; 

public interface IBindesh
{
    string encode(string str);
    string decode(string str);
}

namespace EncryptionDecryption
{
    /// 
    /// 加密解密
    /// 
    public class EncryptionDecryption : IBindesh
    {
        public string encode(string str)
        {
            string htext = ""; 

            for ( int i = 0; i < str.Length; i++)
            {
                htext = htext + (char) (str[i] + 10 - 1 * 2);
            }
            return htext;
        }

        public string decode(string str)
        {
            string dtext = ""; 

            for ( int i=0; i < str.Length; i++)
            {
                dtext = dtext + (char) (str[i] - 10 + 1*2);
            }
            return dtext;
        }
    }

    public class test
    {
        public static void aa()
        {
            EncryptionDecryption inter = new EncryptionDecryption();
            Console.WriteLine(((IBindesh)inter).encode("aa"));
            System.Console.ReadLine();
        }
    }
}
posted on 2008-09-17 00:44  VocanoLee  阅读(1197)  评论(3)    收藏  举报