首页 > 开发 > 综合 > 正文

给大家一个新的加密方法,C#的。(国外的,只用于学习,支持中文)

2024-07-21 02:16:52
字体:
来源:转载
供稿:网友
using system;

/* the reason that i am using interface is that, in several
* weeks i will use a bitwise operator for have encryption and decryption
* */
public interface ibindesh
{
    string encode(string str);
    string decode(string str);
}

namespace encryptiondecryption
{
    /// <summary>
    /// summary description for encryptiondecryption.
    /// </summary>
    public class encryptiondecryption : ibindesh
    {
        public string encode(string str)
        {
            string htext = ""; // blank text

            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;
        }
    }
}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表