• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

传奇3外挂加密解密过程(C#)版

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
加密算法1:
        public string Base64Encode(string source)
         {
             byte[] a1,a2,a3;
             BitArray b1,b2,b3;
             a1 = Encoding.Default.GetBytes(source);
            if (a1.Length % 3 == 0) a2 = new byte[a1.Length*4/3];
            else a2 = new byte[a1.Length*4/3+1];
             a3 = new byte[1];
             b1 = new BitArray(a1);
             b2 = new BitArray(6);
             b3 = new BitArray(b1.Length);
            for (int i = 0, k = b1.Length / 8; i < k; i++) 
             {
                for(int j=7;j>=0;j--)b3[i*8+j]=b1[i*8+7-j];
             }
            for (int i = 0,k=b1.Length/6; i < k; i++)
             {
                for (int j = 0; j < 6; j++)
                 {
                     b2[5-j] = b3[i * 6 + j];
                 }
                 b2.CopyTo(a3,0);
                 a2[i] = a3[0];
             }
            if (a1.Length % 3 == 1) a2[a2.Length - 1] = (byte)((byte)(a1[a1.Length - 1] << 6) >> 2);
            else if (a1.Length % 3 == 2) a2[a2.Length - 1] = (byte)((byte)(a1[a1.Length - 1] << 4 )>> 2);
            for (int i=0; i < a2.Length; i++) a2[i] = (byte)(a2[i] + 0x3c);
            return Encoding.Default.GetString(a2);
         }

加密算法2:

        public string Base64Encode(string source)
         {
             byte[] a1, a2;
             a1 = Encoding.Default.GetBytes(source);
            if (a1.Length % 3 == 0) a2 = new byte[a1.Length * 4 / 3];
            else a2 = new byte[a1.Length * 4 / 3 + 1];
            for (int i = 0, k = a1.Length / 3; i < k; i++) 
             {
                 a2[i*4] = (byte)(a1[i*3] >> 2);
                 a2[i*4 + 1] = (byte)((byte)((byte)(a1[i*3] << 6) >> 2) + (byte)(a1[i*3 + 1] >> 4));
                 a2[i*4 + 2] = (byte)((byte)((byte)(a1[i*3 + 1] << 4) >> 2) + (byte)(a1[i*3 + 2] >> 6));
                 a2[i*4 + 3] = (byte)((byte)(a1[i*3 + 2] << 2) >> 2);
             }
            if (a1.Length % 3 == 1)
             {
                 a2[a2.Length - 2] = (byte)(a1[a1.Length - 1] >> 2);
                 a2[a2.Length - 1] = (byte)((byte)(a1[a1.Length - 1] << 6) >> 2);
             }
            else
                if (a1.Length % 3 == 2)
                 {
                     a2[a2.Length - 3] = (byte)(a1[a1.Length - 2] >> 2);
                     a2[a2.Length - 2] = (byte)((byte)((byte)(a1[a1.Length - 2] << 6) >> 2) + (byte)(a1[a1.Length - 1] >> 4));
                     a2[a2.Length - 1] = (byte)((byte)(a1[a1.Length - 1] << 4) >> 2);
                 }
            for (int i = 0; i < a2.Length; i++) a2[i] = (byte)(a2[i] + 0x3c);
            return Encoding.Default.GetString(a2);
         }

解密算法:

        public string Base64Decode(string source) 
         {
             byte[] a1, a2;
             a1 = Encoding.Default.GetBytes(source);
             a2 = new byte[a1.Length * 3 / 4];
            for (int i = 0; i < a1.Length; i++) a1[i] = (byte)(a1[i] - 0x3c);
            for (int i = 0, k = a1.Length / 4; i < k; i++)
             {
                 a2[i * 3] = (byte)((byte)(a1[i * 4] << 2) + (byte)(a1[i * 4 + 1] >> 4));
                 a2[i * 3 + 1] = (byte)((byte)(a1[i * 4 + 1] << 4) + (byte)(a1[i * 4 + 2] >> 2));
                 a2[i * 3 + 2] = (byte)((byte)(a1[i * 4 + 2] << 6) + a1[i * 4 + 3]);
             }
            if (a2.Length % 3 == 2)
             {
                 a2[a2.Length - 2] = (byte)((byte)(a1[a1.Length - 3] << 2) + (byte)(a1[a1.Length - 2] >> 4));
                 a2[a2.Length - 1] = (byte)((byte)(a1[a1.Length - 2] << 4) + (byte)(a1[a1.Length - 1] >> 2));
             }
            else
            if (a2.Length % 3 == 1) a2[a2.Length - 1] = (byte)((byte)(a1[a1.Length - 2] << 2) + (byte)(a1[a1.Length - 1] >> 4));
            return Encoding.Default.GetString(a2);
         }

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C#插件式程序开发发布时间:2022-07-10
下一篇:
C#模拟Form提交发布时间:2022-07-10
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap