delphi 分享三个随机字符串
uses math; function GenID:String;
var
b, x: byte;
begin
Result := '{';
Randomize;
for b:= to do
begin
if Random() > then Result := Result + chr(RandomRange(,))
else Result := Result + chr(RandomRange(,));
end;
Result := Result + '-';
for x:= to do
begin
for b:= to do
begin
if Random() < then Result := Result + chr(RandomRange(,))
else Result := Result + chr(RandomRange(,));
end;
Result := Result + '-';
end;
for b:= to do
begin
if Random() < then Result := Result + chr(RandomRange(,))
else Result := Result + chr(RandomRange(,));
end;
Result := Result + '}';
end; function genkey :string;
const
Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
var
S: string;
i, N: integer;
begin
Randomize;
S := '';
for i := to do begin
N := Random(Length(Chars)) + ;
S := S + Chars[N];
end;
result := S;
end; function genkey2(c:integer) :string;
const
Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
var
S: string;
i, N: integer;
begin
if c < then c := ;
Randomize;
S := '';
for i := to c do begin
N := Random(Length(Chars)) + ;
S := S + Chars[N];
end;
result := S;
end; procedure TForm1.FormCreate(Sender: TObject);
begin
memo1.Lines.Add(GenID);
memo1.Lines.Add(genkey);
memo1.Lines.Add(genkey2());
end;
delphi 分享三个随机字符串的更多相关文章
- 【分享】JS生成随机字符串
之前忘了从哪里找到的一段代码,整理电脑时,记录为博文备查,原创不是我. function randomString(len) { len = len || 32; var $chars = 'ABCD ...
- [终章]进阶20-流程控制结构--if/case/while结构 - 三个while的存储过程案例(批量生成表单数据) - 随机长度的随机字符串的存储过程案例
. mysql 存储过程中尽量使用 @变量 而不用局部变量, @变量不容易报错!权限小,更改一下就报错! . sql中判断相等'=' ,用'=' 不用'=='. . #流程控制结构 /* 顺序结构: ...
- random and password 在Linux下生成crypt加密密码的方法,shell 生成指定范围随机数与随机字符串
openssl rand -hex n (n is number of characters) LANG=c < /dev/urandom tr -dc _A-Z-a-z-0-9 | head ...
- Mysql 自定义随机字符串
前几天在开发一个系统,需要用到随机字符串,但是mysql的库函数有没有直接提供,就简单的利用现有的函数东拼西凑出随机字符串来.下面简单的说下实现当时. 1.简单粗暴. select ..., subs ...
- Python生成随机字符串
利用Python生成随机域名等随机字符串. #!/usr/bin/env python# -*- coding: utf-8 -*- from random import randrange, cho ...
- js 格式化时间、字符串指定长度、随机字符串
格式化字符串长度 方法 function formatWidth(str, width){ str += '' if(str.length<width) '+str, width) else r ...
- mysql中的 随机字符串的生成
方法1. SELECT SUBSTRING(MD5(RAND()),FLOOR(RAND()*26)+1,6) AS rand_str; 上诉示例产生的是:6位长度的随机字符串. 函数解释: rand ...
- php获取随机字符串的几种方法
方法一:shuffle函数(打乱数组)和mt_rand函数(生成随机数,比rand速度快四倍) /** * 获得随机字符串 * @param $len 需要的长度 * @param $special ...
- delphi连接sql server的字符串2011-10-11 16:07
delphi连接sql server的字符串2011-10-11 16:07 一.delphi连接sql server 放一个连接组件 ADOConnection, 其它组件TADODataSet,T ...
随机推荐
- node.js 关于 async的使用
第一次使用,感觉有点糊涂,后来实验明白了. 在串行执行中,经常会只做了第一步.后来明白了.是没有把回调函数放在里面简单就是: async.series( { ...
- Nowcoder OI赛制测试2 F 假的数学题 - 斯特林公式 + 二分
Description 给定$X$, 找到最小的$N$ 使得$N! > X^X$ 数据范围: $x <= 1e11$ Solution $X^X$ 太大, 高精也存不过, 所以取对数 : ...
- 如何使用AE来制作烟雾粒子特效
1. 首先,我们先建立一个合成,大小1280×720,帧速率25,持续时间为10秒,建好后,再新建一个固态层点击确定. 2.点击效果添加Particular粒子插件 3. 点开粒子插件的发射器,方 ...
- linux学习第二天 (Linux就该这么学)
2018年11月10日,今天是学习的第二天 今天学习了安装vmware workstation12的安装及怎么安装 redhat7系统,在新建虚拟机时注意要选择“稍后安装操作系统”要vmwark wo ...
- Maven 下载安装
http://www.runoob.com/maven/maven-tutorial.html https://www.yiibai.com/maven/ Maven 提倡使用一个共同的标准目录结构, ...
- paxos 练手 推进中
学习https://github.com/huoyu820125/SecondPaxos 自己编写网络版本 在学习过程将此代码的线程 锁等改成c++11 就不用包含那么多文件 主要更改如下 // M ...
- IOS初级:NSKeyedArchiver
NSKeyedArchiver对象归档 首先要实现<NScoding>里面的两个代理方法initWithCoder,encodeWithCoder @property (nonatomic ...
- 2018.11.24 poj1743Musical Theme(二分答案+后缀数组)
传送门 代码: 二分答案. 然后对于预处理的heightheightheight数组分成几段. 保证每一段中都是连续的几个heightheightheight并且这些heightheightheigh ...
- 高效能程序员的七个习惯【csdn】
从网上看到的,感觉挺不错的! Beautiful is better than ugly. Explicit is better than implicit. Simple is better tha ...
- hadoop yarn组件介绍
Yarn的产生 mapReduc1.0 1单点故障 2扩展效率低 3资源利用率高 降低运维成本 方便数据共享 多计算框架支持 MapReduce Spark Storm Yarn的架构图 Yarn模块 ...