this.治疗完毕

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

C#des对文件进行加密解密

     //编码输入的字符串
        private static string EncodeString(string source)
        {
            byte[] bytes = System.Text.Encoding.UTF8.GetBytes(source);
            for (int i = 0; i < bytes.Length; i++)
            {
                bytes[i] ^= (byte)(i & 0x0095);
            }
            return Convert.ToBase64String(bytes);
        }
        //解码传入的字符串
        private static string DecodeString(string source)
        {
            byte[] bytes = Convert.FromBase64String(source);
            for (int i = 0; i < bytes.Length; i++)
            {
                bytes[i] ^= (byte)(i & 0x0095);
            }
            return System.Text.Encoding.UTF8.GetString(bytes);
        }

 

posted on 2018-05-31 15:53  this.治疗完毕  阅读(191)  评论(0)    收藏  举报