乱码加密解密


加密后

clipboard

乱码加密解密

加密后

        /// <summary>
        /// 加密
        /// </summary>
        /// <param name="str"></param>
        /// <param name="key">数值1-1024</param>
        /// <returns>加密后文件是乱码的</returns>
        public static string MakePasswordText(string str, int key)
        {
            //string str = "ABCED";
            string s = "";
            foreach (char ch in str)
            {
                s += (char)((int)ch + key);
            }
            return s;
        }




  解密后

       /// <summary>
        /// 解密
        /// </summary>
        /// <param name="str"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public static string JMText(string str, int key)
        {
            //string str = "ABCED";
            string s = "";
            foreach (char ch in str)
            {
                s += (char)((int)ch - key);
            }
            return s;
        }


解密后

clipboard

posted @ 2020-09-13 21:36  XE2011  阅读(2170)  评论(0编辑  收藏  举报