WEB开发网
开发学院数据库MySQL 实际应用:MySQL5存储过程编写 阅读

实际应用:MySQL5存储过程编写

 2008-09-09 11:09:13 来源:WEB开发网   
核心提示: CREATE PROCEDURE `pro_addmm`(IN inpass varchar(10),OUT outpass varchar(11))BEGINdeclare string_in varchar(39);declare string_out varchar(78);decl

  CREATE PROCEDURE `pro_addmm`(IN inpass varchar(10),OUT outpass varchar(11))
BEGIN
declare string_in varchar(39);
declare string_out varchar(78);
declare offset tinyint(2);
declare len tinyint;
  set outpass=';
  set len=LENGTH(inpass);
if((len<=0) or (len>10)) then
set outpass=';
else
set offset=(SECOND(NOW()) mod 39)+1;
  set string_out='YN8K1JOZVURB3MDETS5GPL27AXWIHQ94C6F0#$_';
set string_in='_$#ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
  set outpass=CONCAT(outpass,SUBSTRING(string_out,offset,1));
  set string_out=CONCAT(string_out,string_out);
set @i=0;
REPEAT
set @i=@i+1;
set outpass=CONCAT(outpass,SUBSTR(string_out,INSTR(string_in,SUBSTRING
(inpass,@i,1))+offset,1));
UNTIL (@i>=len)
end REPEAT;
end if;
END

执行结果如下:

  mysql> call pro_addmm('zhouys',@a);
Query OK, 0 rows affected (0.00 sec)
  mysql> SELECT @a;
+---------+
| @a |
+---------+
| U_PI6$4 |
+---------+
1 row in set (0.00 sec)
  mysql> call pro_addmm('zhouys',@a);
Query OK, 0 rows affected (0.00 sec)
  mysql> SELECT @a;
+---------+
| @a |
+---------+
| 9P8UEGM |
+---------+
1 row in set (0.00 sec)
  mysql> select fun_submm('U_PI6$4');
+----------------------+
| fun_submm('U_PI6$4') |
+----------------------+
| ZHOUYS |
+----------------------+
1 row in set (0.00 sec)

加密算法有几个弱点:

1、不支持大小写

2、不支持中文

3、加密强度不够

有兴趣的人可以研究一下解密函数如何编写,这里就不赘述了。

上一页  1 2 3 

Tags:实际 应用 MySQL

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接