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 ...
随机推荐
- MyBatis Generator介绍
MyBatis Generator介绍 MyBatis Generator (MBG) 是一个Mybatis的代码生成器 MyBatis 和 iBATIS. 他可以生成Mybatis各个版本的代码,和 ...
- PHP数组对象互转
//数组转对象 function array2object($array) { if (is_array($array)) { $obj = new StdClass(); foreach ($arr ...
- WCF路由服务
代码下载: 链接:https://pan.baidu.com/s/1i76Ht0lMWmosaCrDjaA2cA 密码:muj11.新建类库 Service.Interface using Syste ...
- 【UI测试】--安全性
- canvas 实现微信小游戏
var canvas = document.getElementById('canvas'); var cxt = canvas.getContext('2d'); var timer; var iS ...
- canvas 实现弹跳效果
一:创建画布 <canvas width="600" height="600" id="canvas"></canvas& ...
- 多项式相关&&生成函数相关&&一些题目(updating...)
文章目录 多项式的运算 多项式的加减法,数乘 多项式乘法 多项式求逆 多项式求导 多项式积分 多项式取对 多项式取exp 多项式开方 多项式的除法/取模 分治FFT 生成函数 相关题目 多项式的运算 ...
- 2018.11.01 NOIP训练 树的排列(树形dp)
传送门 跟这道题差不多. 只不过是让权值小的儿子做权值大的儿子的父亲而已. 代码
- centos7 新增ip
1.进入network-scripts目录:cd /etc/sysconfig/network-scripts/ 2.复制ifcfg-eth0: cp ifcfg-eth0 ifcfg-eth0:0 ...
- django调用py报错 django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not configured.
完整报错信息如下 django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, bu ...