随机密码生成器,MySQL 随机密码生成代码

复制代码 代码如下:

DELIMITER $$

CREATE
FUNCTION `t_girl` . `func_rand_string` ( f_num tinyint unsigned , f_type tinyint unsigned )
RETURNS varchar ( 32)
BEGIN
-- Translate the number to letter.
-- No 1 stands for string _disibledevent=>set v_result = concat ( v_result, char ( 97+ ceil( rand ( ) * 25) ) ) ;
elseif f_type= 2 then
set v_result = concat ( v_result, char ( 48+ ceil( rand ( ) * 9) ) ) ;
elseif f_type= 3 then
set v_result = concat ( v_result, substring ( replace ( uuid ( ) , '-' , '' ) , i+ 1, 1) ) ;
end if;
set i = i + 1;
end while;
return v_result;

END $ $

DELIMITER ;


调用方法示例:
复制代码 代码如下:

select func_rand_string(12,3);

Tags:  mysql随机 随机密码生成 随机密码生成器

延伸阅读

最新评论

发表评论