惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Attack and Defense Labs
Attack and Defense Labs
The GitHub Blog
The GitHub Blog
C
Check Point Blog
博客园_首页
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
F
Full Disclosure
Microsoft Security Blog
Microsoft Security Blog
爱范儿
爱范儿
Recent Announcements
Recent Announcements
阮一峰的网络日志
阮一峰的网络日志
G
GRAHAM CLULEY
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Threat Research - Cisco Blogs
C
Cybersecurity and Infrastructure Security Agency CISA
V
Vulnerabilities – Threatpost
K
Kaspersky official blog
博客园 - 司徒正美
S
Schneier on Security
T
The Exploit Database - CXSecurity.com
Project Zero
Project Zero
云风的 BLOG
云风的 BLOG
Cisco Talos Blog
Cisco Talos Blog
Know Your Adversary
Know Your Adversary
雷峰网
雷峰网
V
V2EX - 技术
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Spread Privacy
Spread Privacy
罗磊的独立博客
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
SecWiki News
SecWiki News
Schneier on Security
Schneier on Security
O
OpenAI News
Jina AI
Jina AI
PCI Perspectives
PCI Perspectives
Cyberwarzone
Cyberwarzone
Y
Y Combinator Blog
Apple Machine Learning Research
Apple Machine Learning Research
B
Blog RSS Feed
I
InfoQ
D
Docker
P
Palo Alto Networks Blog
Recorded Future
Recorded Future
M
MIT News - Artificial intelligence
博客园 - Franky
B
Blog
Scott Helme
Scott Helme
博客园 - 叶小钗
D
DataBreaches.Net

博客园 - Casm

C#代码与javaScript函数的相互调用 窗口A打开窗口B,关闭窗口B,窗口B关闭窗口A(web窗口互关问题) - Casm - 博客园 3G网络 无聊~写个计算器...待续 下拉框的郁闷! - Casm 一个记事本的例子(作者kiki) 关闭用户打开的进程处理 如何在Vista IIS 7 中用 vs2005 调试 Web 项目 回顾windows界面的20年历程(三)(转) 回顾windows界面的20年历程(二)(转) 回顾windows界面的20年历程(一)(转) google的历史 一个新手的成长过程 传奇3加密解密-VB2005 VB 热血江湖V170外挂 全部 源码 给学做嵌入式开发外挂技术的新人一点建议 网络游戏外挂编写基础(1) 到处都有,但是自己还是要常常看看! 使用vs2005调试javascript
传奇3封包加解密C#版
Casm · 2007-04-26 · via 博客园 - Casm

加密算法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);
        }