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

推荐订阅源

TaoSecurity Blog
TaoSecurity Blog
Jina AI
Jina AI
雷峰网
雷峰网
月光博客
月光博客
The GitHub Blog
The GitHub Blog
WordPress大学
WordPress大学
B
Blog RSS Feed
美团技术团队
C
CXSECURITY Database RSS Feed - CXSecurity.com
小众软件
小众软件
Security Latest
Security Latest
Microsoft Azure Blog
Microsoft Azure Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cybersecurity and Infrastructure Security Agency CISA
Last Week in AI
Last Week in AI
A
Arctic Wolf
Latest news
Latest news
Attack and Defense Labs
Attack and Defense Labs
I
Intezer
F
Fortinet All Blogs
罗磊的独立博客
MongoDB | Blog
MongoDB | Blog
Webroot Blog
Webroot Blog
S
Secure Thoughts
Help Net Security
Help Net Security
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
V
Visual Studio Blog
P
Proofpoint News Feed
博客园 - 【当耐特】
P
Privacy International News Feed
V
Vulnerabilities – Threatpost
Stack Overflow Blog
Stack Overflow Blog
Know Your Adversary
Know Your Adversary
云风的 BLOG
云风的 BLOG
Hacker News: Ask HN
Hacker News: Ask HN
L
LINUX DO - 最新话题
H
Help Net Security
爱范儿
爱范儿
酷 壳 – CoolShell
酷 壳 – CoolShell
S
SegmentFault 最新的问题
Forbes - Security
Forbes - Security
T
Tailwind CSS Blog
量子位
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
Tenable Blog
Cloudbric
Cloudbric
N
News and Events Feed by Topic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Hugging Face - Blog
Hugging Face - Blog

博客园 - tronic

进度条HTML - tronic - 博客园 linq操作datatable - tronic - 博客园 ASP.NET中漂亮的弹出对话框 C# 操作数据库,数据库表 实现MSN弹出窗口特效示例代码 - tronic - 博客园 加密和解密运算代码 - tronic - 博客园 在应用程序级别之外使用注册为 allowDefinition='MachineToApplication' 的节是错误的 CreateUserWizard的控件插得很深 - tronic - 博客园 保留一下遍历页面所有控件的方法 C#中web.config文件详解 招聘 ASP.NET程序员 任何调用的结束,一定要Dispose 可视化操作常见错误的解决方法 使用WebClient自动填写并提交ASP.NET页面表单 任何时候使用POST数据都要URLENCODE 获取图片地址代码(严格按HTML编写的图片地址) 正则表达式获取内容中的数字 Asp.Net性能优化. Asp.Net细节性问题技巧精萃
生成n位不同的验证码
tronic · 2007-04-17 · via 博客园 - tronic

public string RandomNum(int n) //
{
 string strchar = "0,1,2,3,4,5,6,7,8,9" ;
 string[] VcArray = strchar.Split(',') ;
 string  VNum = "" ;//由于字符串很短,就不用StringBuilder了
 int temp = -1 ;    //记录上次随机数值,尽量避免产生几个一样的随

机数
 //采用一个简单的算法以保证生成随机数的不同
 Random rand =new Random();
 for ( int i = 1 ; i < n+1 ; i++ )
 {   
  if ( temp != -1)
  {
   rand =new Random(i*temp*unchecked((int)

DateTime.Now.Ticks));
  }   
  //int t =  rand.Next(35) ;
  int t=rand.Next(10);
  if (temp != -1 && temp == t)
  {
   return RndNum( n);
  }
  temp = t  ;
  VNum += VcArray[t];
  }
 return VNum ;//返回生成的随机数
}