shell生成随机字符串】的更多相关文章

#!/bin/bash i=1while [ $i -le 10000 ]doa=`echo `< /dev/urandom tr -dc A-Za-z0-9 | head -c6``echo -n -e "$a\t"b=`echo `< /dev/urandom tr -dc 0-9 | head -c6``echo "$b"i=`expr $i + 1`done   PS:---------------------------------------…
生成随机字符串的工具类: /// <summary> /// 随机字符串工具类 /// </summary> public class RandomTools { /// <summary> /// 随机系数 /// </summary> ; #region 获取某个区间的一个随机数 /// <summary> /// 获取某个区间的一个随机数 /// </summary> /// <param name="minim…
说明:生成随机字符串用到的方法有 mt_rand() 生成唯一字符串用到的方法有 md5(),uniqid(),microtime() 代码: <?php /* * 生成随机字符串 * @param int $length 生成随机字符串的长度 * @param string $char 组成随机字符串的字符串 * @return string $string 生成的随机字符串 */ function str_rand($length = 32, $char = '0123456789abcde…
PHP生成随机字符串包括大小写字母,这里介绍两种方法: 第一种:利用字符串函数操作 <?php /** *@blog <www.phpddt.com> */ function createRandomStr($length){ $str = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';//62个字符 $strlen = 62; while($length > $strlen){ $str .= $…
这是另一种用UUID生成随机字符串的方法. public class RandomGenerator{ private int length; public void setLength(int length) { this.length = length; } public RandomGenerator(int length){ this.length=length; } public RandomGenerator(){ this.length=32; } public String ge…
1.SQLserve生成随机字符串 SELECT replace(newid(), '-', '')…
php 生成随机字符串 可以指定是纯数字 还是纯字母 或者混合的. 可以指定长度的. function rand_zifu($what,$number){ $string=''; for($i = 1; $i <= $number; $i++){ //混合 $panduan=1; if($what == 3){ if(rand(1,2)==1){ $what=1; }else{ $what=2; } $panduan=2; } //数字 if($what==1){ $string.=rand(0…
这篇文章主要介绍了JS生成随机字符串的方法,需要的朋友可以参考下 下面的一段代码,整理电脑时,记录备查. <script language="javascript"> function randomString(len) { len = len || 32; var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/ var…
代码如下: <?php /* * 生成随机字符串 * @param int $length 生成随机字符串的长度 * @param string $char 组成随机字符串的字符串 * @return string $string 生成的随机字符串 */ function str_rand($length = , $char = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') { ) { return false…
* 生成随机字符串* @param int       $length  要生成的随机字符串长度* @param string    $type    随机码类型:0,数字+大小写字母:1,数字:2,小写字母:3,大写字母:4,特殊字符:-1,数字+大小写字母+特殊字符* @return string*/ function randCode($length = 5, $type = 0) {       $arr = array(1 => "0123456789", 2 =>…
简单的生成随机字符串: /* * 生成随机字符串 * * $length 字符串长度 */ function random_str($length) { // 密码字符集,可任意添加你需要的字符 $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; $str = ''; for($i = 0; $i < $length; $i++) { // 这里提供两种字符获取方式 // 第一种是使用 substr…
原文连接 Objective-C版 // 随机生成字符串(由大小写字母.数字组成) + (NSString *)random: (int)len { char ch[len]; for (int index=0; index<len; index++) { int num = arc4random_uniform(75)+48; if (num>57 && num<65) { num = num%57+48; } else if (num>90 &&…
1.生成随机字符串 #数字+字母+符号 def getRandChar(n): l = [] #sample = '0123456789abcdefghijklmnopqrstuvwxyz!@#$%^&*()-+=.' sample = random.sample(string.ascii_letters + string.digits, 62)## 从a-zA-Z0-9生成指定数量的随机字符: list类型 sample = sample + list('!@#$%^&*()-+=.')…
/** +---------------------------------------------------------- * 生成随机字符串 +---------------------------------------------------------- * @param int $length 要生成的随机字符串长度 * @param string $type 随机码类型:0,数字+大小写字母:1,数字:2,小写字母:3,大写字母:4,特殊字符:-1,数字+大小写字母+特殊字符 +…
/* * 名称:RandomId * 功能:生成随机ID * 作者:冰麟轻武 * 日期:2012年1月31日 03:36:28 * 版本:1.0 * 最后更新:2012年1月31日 03:36:28 */ using System; using System.Text; namespace blqw { public sealed class RandomId : IFormattable { /// <summary> 1234567890qwertyuiopasdfghjklzxcvbnm…
随机字符串 - 生成指定长度的字符串 -(NSString *)randomStringWithLength:(NSInteger)len { NSString *letters = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; NSMutableString *randomString = [NSMutableString stringWithCapacity: len]; for (NSInte…
利用Python生成随机域名等随机字符串. #!/usr/bin/env python# -*- coding: utf-8 -*- from random import randrange, choice from string import ascii_lowercase as lc from sys import maxsize from time import ctime tlds = ('com', 'edu', 'net', 'org', 'gov') for i in range(…
1.生成之指定位数的随机字符串 /** * 随机基数 */ private static char[] charset = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'g', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'G', 'K', 'L…
网上有很多的php随机数与验证码的代码与文章,真正适用的没有几个. 索性自己搞一个吧. 开始本节的php教程 吧,以下代码的实现,主要做到可以很好区分一个get_code(),另一个create_check_image(),输出图像直接调用后面的,session()取验证码时直接get_code()就ok,顺带提下使用session时必须将session_star()放在最前面. 代码如下: [php] view plaincopy <?php class RandCheckCode { /*函…
//返回一个指定范围内的随机数 function createRandomNum(Min,Max){ let Range = Max - Min; let Rand = Math.random(); return(Min + Math.round(Rand * Range)); } createRandomNum(2,11); //3 //返回一个指定长度的随机字符串 let chars = ['0','1','2','3','4','5','6','7','8','9','A','B','C'…
之前忘了从哪里找到的一段代码,整理电脑时,记录为博文备查,原创不是我. function randomString(len) { len = len || 32; var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/ var maxPos = $chars.length; var pwd = ''; for (i = 0; i < len;…
生成三位随机字母+12位数字 ),), @c int; select @CardCode=abs(CHECKSUM(NEWID())) -LEN(@CardCode); ,@c)) set @CardCode=@CardCode+@str ) ,) ; ) )+ )) )+ )) ) )) 下面这个是生成大写字母的 ) ,) ; ) )+ )) )+ )) ) select @name 生成随机字母+数字的存储过程 ALTER proc [dbo].[randStr] ( @digitalLen…
/**     * 获取随机字符串     * @param $lenth     * @return string     */     function getRandStr($lenth = 20)    {             $strData = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';        $randString = '';        $max = strlen($strDat…
一直使用 /dev/urandom 和md5sum的方式去随机字符串,感觉还是不够随机,毕竟只有小写字母和数字嘛. 换换口味: [root@localhost ~]# arr=(`echo {a..z} \# \@ \% \& {0..9} \! \; \? {A..Z} \> \+ \= `) ; str="" ; for i in `seq 18` ; do str=${str}${arr[`echo $RANDOM % ${#arr[*]} | bc`]}; don…
#!/bin/bash # bash generate random alphanumeric string # # bash generate random character alphanumeric string (upper and lowercase) and NEW_UUID=$( | ) # bash generate random character alphanumeric string (lowercase only) | # Random numbers in a rang…
//<summary> ///得到随机字符. ///</summary> ///<param name="intLength">Length of the int.</param> ///<param name="booNumber">if set to <c>true</c> [boo number].</param> ///<param name="b…
应用python random标准库做一个随机生成密码的程序,可以随机生成任意多个字符.(基于python2.7,如果是python3需要修改下) 案例: #-*-coding:utf-8 -*-#author:wangxing import randomimport stringimport sys #存储大小写字母和数字,特殊字符列表STR = [chr(i) for i in range(65,91)] #65-91对应字符A-Zstr = [chr(i) for i in range(9…
python解释器示例 >>> import uuid >>> uuid.uuid1() UUID('ae6822e6-c976-11e6-82e0-0090f5f61084') >>> uuid.uuid1() UUID('af72c0a2-c976-11e6-b69e-0090f5f61084') >>> uuid.uuid1() UUID('afd03ab6-c976-11e6-8475-0090f5f61084') >&…
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { //int number; //int count = 7; //string checkCode =…
学习java comparable特性时候,定义如下Student类,需要需要随机添加学生姓名以及学号和成绩,这是java如何随机生成名字,根据我的查询,我找到目前java库支持两种方法. 1. org.apache.commons.lang3.RandomStringUtils类,他支持方法可以到RandomStringUtils查询,其中有一个方法: public static java.lang.String random(int count, int start, int end, bo…