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 ...
随机推荐
- Luogu 3424 [POI2005]SUM-Fibonacci Sums
Solution 没有任何算法, 只要会$for$ 就能AC... 我们观察到, 如果有一个位置 的$F_i$ 的系数$b_i$ 为2, 那么只需要把 $b_{i-2}+1,b_{i+1}+1$即可. ...
- c sharp multithreading
1. 静态方法 using System; using System.Threading; namespace PlusThread { class Program { static void Ma ...
- Spring 系列教程之默认标签的解析
Spring 系列教程之默认标签的解析 之前提到过 Spring 中的标签包括默认标签和自定义标签两种,而两种标签的用法以及解析方式存在着很大的不同,本章节重点带领读者详细分析默认标签的解析过程. 默 ...
- 知名APP(支付宝、微信、花瓣等)首页设计技巧及原型实例讲解
APP首页设计对APP自身来说是至关重要的,一款优秀的APP产品,其首页设计不仅需要清晰的展示产品核心功能,给用户创造良好的用户体验,而且还需要展示公司的品牌形象,提升在用户心中的品牌认知度.今天,就 ...
- Sort Array By Parity LT905
Given an array A of non-negative integers, return an array consisting of all the even elements of A, ...
- spring security 4.2后出现CouldnotverifytheprovidedCSRFtokenbecauseyoursessionwasnotfound
升级到spring security 4.2后,登录不了,出现下面的错误 WARN DefaultHandlerExceptionResolver:361 - Failed to bind reque ...
- spring事件机制
前置知识补充: 程序里面所谓的“上下文”就是程序的执行环境,打个比方:你就相当于web程序,你的房子就相当于web程序的上下文,你可以在家里放东西,也可以取东西,你的衣食住行都依赖这个房子,这个房子就 ...
- 使用adb shell 模拟点击事件
针对问题[appium无法点击到某一内容,需要使用adb去执行点击事件] 需要命令: adb shell adb devices input [input可以实现的功能]: 输入文本信息:input ...
- js网页上画图
保存 1.d3.js (http://www.d3.org/)使用svg技术,展示大数据量,动态效果很好,但是API暴露的不好,得靠自己摸索. 2.http://raphaeljs.com/refe ...
- Keras框架下使用CNN进行CIFAR-10的识别测试
有手册,然后代码不知道看一下:https://keras-cn.readthedocs.io/en/latest/ 首先是下载数据集,下载太慢了就从网盘上下载: 链接:https://pan.baid ...