zoukankan      html  css  js  c++  java
  • 用MySQL 生成随机密码增加大写处理

    以前写过:

    http://blog.chinaunix.net/uid-259788-id-2139370.html


    这次增加了大写字母的处理。



    DELIMITER $$
    
    USE `t_girl`$$
    
    DROP FUNCTION IF EXISTS `func_rand_string`$$
    
    CREATE DEFINER=`root`@`localhost` FUNCTION `func_rand_string`(f_num TINYINT UNSIGNED,f_type TINYINT UNSIGNED) RETURNS VARCHAR(32) CHARSET utf8
    BEGIN
          -- Translate the number to letter.
          -- No 1 stands for string only.
          -- No 2 stands for number only.
          -- No 3 stands for combination of the above.
          DECLARE i INT UNSIGNED DEFAULT 0;
          DECLARE v_result VARCHAR(255) DEFAULT '';
          WHILE i < f_num DO
            IF f_type = 1 THEN
              SET v_result = CONCAT(v_result,CHAR(65+32*(CEIL(RAND()*2)-1)+CEIL(RAND()*25)));
            ELSEIF f_type=2 THEN
              SET v_result = CONCAT(v_result,CEIL(RAND()*9));
            ELSEIF f_type=3 THEN
              IF (CEIL(RAND()*2)-1) = 1 THEN
                SET v_result = CONCAT(v_result,SUBSTRING(REPLACE(UUID(),'-',''),i+1,1));
              ELSE 
                SET v_result = CONCAT(v_result,UPPER(SUBSTRING(REPLACE(UUID(),'-',''),i+1,1)));
              END IF;
            END IF;
            SET i = i + 1;
          END WHILE; 
          RETURN v_result;
        END$$
    
    DELIMITER ;


    调用方法类似。


  • 相关阅读:
    Colmap在centos7下的编译
    图像搜索三-局部特征SIFT
    docker的基本概念
    图像搜索(二)-全局特征
    图像搜索(一)-好特征
    Android图片生成器
    Android Studio Prower Save Mode问题
    finished with non-zero exit value 1
    安装pod程序
    小米刷入Recovery
  • 原文地址:https://www.cnblogs.com/secbook/p/2655271.html
Copyright © 2011-2022 走看看