随机生成字符串
2007-03-11 19:03
423 查看
function btnGenerateClick(Sender: TObject): string;
{max length of generated password}
const
intMAX_PW_LEN = 10;
var
i: Byte;
s: string;
begin
{if you want to use the 'A..Z' characters}
if cbAZ.Checked then
s := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
else
s := '';
{if you want to use the 'a..z' characters}
if cbAZSmall.Checked then
s := s + 'abcdefghijklmnopqrstuvwxyz';
{if you want to use the '0..9' characters}
if cb09.Checked then
s := s + '0123456789';
if s = '' then exit;
Result := '';
for i := 0 to intMAX_PW_LEN-1 do
Result := Result + s[Random(Length(s)-1)+1];
end;
{max length of generated password}
const
intMAX_PW_LEN = 10;
var
i: Byte;
s: string;
begin
{if you want to use the 'A..Z' characters}
if cbAZ.Checked then
s := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
else
s := '';
{if you want to use the 'a..z' characters}
if cbAZSmall.Checked then
s := s + 'abcdefghijklmnopqrstuvwxyz';
{if you want to use the '0..9' characters}
if cb09.Checked then
s := s + '0123456789';
if s = '' then exit;
Result := '';
for i := 0 to intMAX_PW_LEN-1 do
Result := Result + s[Random(Length(s)-1)+1];
end;
相关文章推荐
- 【分享】JS生成随机字符串
- JS生成1000个数字加字母的不重复的随机字符串
- 012 随机生成n个字节的字符串?
- 在验证码中生成随机字符串
- 生成随机字符串和验证码的类的PHP实例
- java生成随机字符串和随机数
- 生成n位随机字符串(转)
- JQuery生成随机字符串
- Excel生成随机字符串(数字大小写混合)
- 生成大量随机字符串不同实现方式的效率对比
- 随机生成字符串实现
- Python 中的POST/GET包构建以及随机字符串的生成
- js随机生成字母数字组合的字符串 随机动画数字
- php 随机生成一个字符串
- shell 生成指定范围随机数与随机字符串
- Java随机生成长度不少于6的指定长度的密码,且这个字符串必须包含大小写字母、数字和特殊字符,四种的任意三种
- js 生成随机字符串
- 生成随机字符串的SQL实现
- ASP生成随机字符串(数字+大小写字母)的代码
- c# 生成指定位数的随机字符串