Home >php教程 >php手册 >php加密和解密

php加密和解密

WBOY
WBOYOriginal
2016-06-13 09:46:001135browse

加密和解密是一项常规任务。用户注册的密码一般不会明文保存,总得加个密先。

最简单的当然是在数据库sql语句中调用md5函数加密用户密码。这里介绍一个加解密类。如果你想在用户忘记密码时为他或她找回原来的密码,那么这个类是个好用的工具。当然,这个加解密类也可用于其他用途。

查看源码

__construct( ->skey = hash("md5", , ); safe_b64encode( = ( = (('+', '/', '='), ('-', '_', ''), safe_b64decode( = (('-', '_'), ('+', '/'), = () % 4 ( .= ('====', ( encode( (! = = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, = mcrypt_create_iv(, = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, ->skey, , MCRYPT_MODE_ECB, (->safe_b64encode( decode( (! = ->safe_b64decode( = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, = mcrypt_create_iv(, = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, ->skey, , MCRYPT_MODE_ECB, ( } View Code

 

 

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn