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

推荐订阅源

V
Visual Studio Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Hugging Face - Blog
Hugging Face - Blog
D
DataBreaches.Net
A
About on SuperTechFans
D
Docker
腾讯CDC
Google DeepMind News
Google DeepMind News
Hacker News - Newest:
Hacker News - Newest: "LLM"
W
WeLiveSecurity
Forbes - Security
Forbes - Security
S
Security @ Cisco Blogs
V
Vulnerabilities – Threatpost
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Know Your Adversary
Know Your Adversary
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
I
InfoQ
P
Privacy International News Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Application and Cybersecurity Blog
Application and Cybersecurity Blog
aimingoo的专栏
aimingoo的专栏
C
Cyber Attacks, Cyber Crime and Cyber Security
S
Secure Thoughts
Stack Overflow Blog
Stack Overflow Blog
T
Tenable Blog
T
Threatpost
P
Proofpoint News Feed
博客园 - 司徒正美
Microsoft Security Blog
Microsoft Security Blog
N
News and Events Feed by Topic
Apple Machine Learning Research
Apple Machine Learning Research
云风的 BLOG
云风的 BLOG
GbyAI
GbyAI
Hacker News: Ask HN
Hacker News: Ask HN
B
Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Microsoft Azure Blog
Microsoft Azure Blog
F
Fortinet All Blogs
Project Zero
Project Zero
Help Net Security
Help Net Security
WordPress大学
WordPress大学
F
Full Disclosure
博客园 - 三生石上(FineUI控件)
O
OpenAI News
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
H
Heimdal Security Blog
Security Latest
Security Latest
T
Tor Project blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Cisco Talos Blog
Cisco Talos Blog

博客园 - 三聪

流操作 如何利用.Net内置类,解析未知复杂Json对象 制作等比环切缩缩图 让window.setTimeout等支持带参数方法 利用NewID()生成随机数 创建缩略图 winform给html提供接口 IE下记住文本框的光标位置 ie下取得iframe里面内容 树冲突 截图片 学习Objective-C: 入门教程 C#根据字节数截取字符串 asp.net本地和全局资料文件的读取方法 jquery实现点击空白的事件 Asp.net 利用Jquery Ajax传送和接收DataTable 用一个最简单方法解决asp.net页面刷新导致数据的重复提交 SOS"未将对象引用设置到对象的实例" .NET调PHP Web Service的典型例子
短网址计算
三聪 · 2011-03-30 · via 博客园 - 三聪

        string chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";private void button1_Click(object sender, EventArgs e)
        {
            
int i = int.Parse(textBox1.Text);
            textBox2.Text 
= EncodeNum(i);
            textBox3.Text 
= DecodeNum(textBox2.Text).ToString();
        }
/// <summary>
        
/// 转码
        
/// </summary>
        
/// <param name="integer"></param>
        
/// <returns></returns>
        private string EncodeNum(int integer)
        {
            
double number = integer;
            
int hex = chars.Length;
            StringBuilder sb 
= new StringBuilder();
            
do
            {
                
//计算指数
                int exp = -1;
                
double value = 0;
                
while (value < number)
                {
                    exp
++;
                    value 
= Math.Pow(hex, exp + 1);
                }
                
//计算对应字符
                double num = number / Math.Pow(hex, exp);
                
int index = Convert.ToInt32(Math.Floor(num));
                sb.Append(chars.Substring(index, 
1));
                number 
= number % Math.Pow(hex, exp);
            } 
while (number > 0);return sb.ToString();
        }
/// <summary>
        
/// 解码
        
/// </summary>
        
/// <param name="s"></param>
        
/// <returns></returns>
        private int DecodeNum(string s)
        {
            
double x = 0;
            
int hex = chars.Length;
            
for (int i = 0; i < s.Length; i++)
            {
                
int exp = s.Length - 1 - i;
                
int num = chars.IndexOf(s.Substring(i, 1));
                x 
+= num * Math.Pow(hex, exp);
            }
return Convert.ToInt32(x);
        }