delphi 生成随机字符串


本文整理自网络,侵删。

  function RandomStr(majuscule:boolean;lowercase:boolean;number:boolean;digit:integer):string;
//大写字母,小写字母,数字,字符串的位数
var
i: Byte;
s: string;
begin
if majuscule then
s := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
else
s := '';

if lowercase then
s := s + 'abcdefghijklmnopqrstuvwxyz';

if number then
s := s + '0123456789';
if s = '' then exit;

Result := '';
for i := 0 to digit-1 do //根据长度来循环
begin
Randomize;//每次都初始化随机种子
Result := Result + s[Random(Length(s)-1)+1];
end;
end;

相关阅读 >>

Delphi api读写ini文件

Delphi百度云服务平台获取token

Delphi判断字符串中是否包含汉字,并返回汉字位置

Delphi findwindow的一些用法

Delphi 实现检测线程类tthread是否结束

Delphi获取系统特殊文件夹路径

pchar和array [0..255] of char的区别

Delphi 获取网络文件大小

Delphi定时器相关的简单例子

Delphi调用cmd并取得输出字符

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...