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 ...
随机推荐
- Linux vps服务器国产面板wdcp的安装和使用方法
对于大多数站长来说,稳定的服务器不可或缺,这是我做网站以来的深刻体会,因为之前我在网站运营方面因这个原因吃了很多亏.在这里说出,只希望朋友们不要像我一样.在网站优化过程中,服务器因素导致排名下滑,甚至 ...
- JeeSite 4.0
http://jeesite.com/ JeeSite 是一个 Java EE 企业级快速开发平台,基于经典技术组合(Spring Boot.Spring MVC.Apache Shiro.MyBat ...
- MySQL Workbench常用快捷键
执行当前SQL语句(即鼠标所在的SQL语句,以 ; 结尾) Ctrl + Enter 执行选中的SQL语句(或执行所有SQL语句) Ctrl + Shift + Enter
- How to ignore files and directories in subversion?
Step 1 Copy the files and directories to other place. Step 2 Delete the files and directories. Step ...
- Python 常用模块之re 正则表达式的使用
re模块用来使用正则表达式.正则表达式用来对字符串进行搜索的工作.我们最应该掌握正则表达式的查询,更改,删除的功能.特别是做爬虫的时候,re模块就显得格外重要. 1.查询 import re a = ...
- solr之创建core(搜索核心,包括索引和数据)的方法
我的solrhome为D:\solrHome\solr step1:进入solrHome会看到collection1文件夹,创建该文件夹的副本,重命名为product 进入product文件夹,进入d ...
- 【搜索】 Find The Multiple
#include<stdio.h> #include<stdlib.h> #include<string.h> bool found; void DFS(unsig ...
- 【Linux】zlib安装
zlib简介 zlib是提供数据压缩用的函式库,由Jean-loup Gailly与Mark Adler所开发,初版0.9版在1995年5月1日发表.zlib使用DEFLATE算法,最初是为libpn ...
- canvas 实现烟花效果
一:创建画布 <canvas width="600" height="600" id="canvas" style="bor ...
- Hibernate 的缓存
Hibernate的一级缓存 什么是缓存?? 1 数据存到数据库里面,数据库本身是文件系统,使用流方式操作文件效率不是很高. 1.1 把数据存到内存里面,不需要使用流方式,可以直接读取内存中数据 ...