PHP加密解密的类
分享一个php加密解密的类,在用户注册的时候发送邮件验证的时候估计会用的到的。
代码如下:
<p>class SysCrypt{</p> private $crypt_key='http://www.scutephp.com';//密钥<br /> public function __construct($crypt_key){<br /> $this->crypt_key=$crypt_key;<br /> }<br /> public function encrypt($txt){<br /> srand((double)microtime()*1000000);<br /> $encrypt_key=md5(rand(0,32000));<br /> $ctr=0;<br /> $tmp='';<br /> for($i=0;$i<strlen($txt);$i++){<br /> $ctr=$ctr==strlen($encrypt_key)?0:$ctr;<br /> $tmp.=$encrypt_key[$ctr].($txt[$i]^$encrypt_key[$ctr++]);<br /> }<br /> return base64_encode(self::__key($tmp,$this->crypt_key));<br /> }<br /> public function decrypt($txt){<br /> $txt=self::__key(base64_decode($txt),$this->crypt_key);<br /> $tmp='';<br /> for($i=0;$i<strlen($txt);$i++){<br /> $md5=$txt[$i];<br /> $tmp.=$txt[++$i]^$md5;<br /> }<br /> return $tmp;<br /> }<br /> private function __key($txt,$encrypt_key){<br /> $encrypt_key=md5($encrypt_key);<br /> $ctr=0;<br /> $tmp='';<br /> for($i=0;$i<strlen($txt);$i++){<br /> $ctr=$ctr==strlen($encrypt_key)?0:$ctr;<br /> $tmp.=$txt[$i]^$encrypt_key[$ctr++];<br /> }<br /> return $tmp;<br /> }<br /> public function __destruct(){<br /> $this->crypt_key=NULL;<br /> }<br /><p>}</p>
该类使用方法:
<p>$sc=new SysCrypt('http://www.scutephp.com');</p>$text='yhm.1234@163.com';<br />$test1=$sc->encrypt($text);<br />echo '原文:',$text;<br />echo '<br />';<br />echo '密文:',$test1;<br />echo "<br/>";<br /><p>echo '解密:',</p><p>$sc->decrypt($test1);</p>
输出结果类似:
原文:yhm.1234@163.com
密文:VSQBZFRpVysCZFVlAWICYghKVGNQMwRkU31bZVFsV28=解密:yhm.1234@163.com

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics





IntelTXT is a hardware-assisted security technology launched by Intel. It can ensure the integrity and security of the server during startup by establishing a protected space between the CPU and BIOS. The full name of TXT is TrustedExecutionTechnology, which is Trusted Execution Technology. Simply put, TXT is a security technology that provides hardware-level protection to ensure that the server has not been modified by malicious programs or unauthorized software when it is started. this one

Methods for converting html to txt include using a text editor, using online conversion tools, and using Python programming. Detailed introduction: 1. To open an HTML file, you can use any text editor, such as Notepad, Sublime Text, etc. To select the content of the entire HTML file, you can press the Ctrl+A shortcut key or drag the mouse to select and copy the selection. The content can be copied by pressing the Ctrl+C shortcut or through the copy option in the right-click menu, opening a new TXT file, using the same text editor, etc.

What is Identity in SQL? Specific code examples are needed. In SQL, Identity is a special data type used to generate auto-incrementing numbers. It is often used to uniquely identify each row of data in a table. The Identity column is often used in conjunction with the primary key column to ensure that each record has a unique identifier. This article will detail how to use Identity and some practical code examples. The basic way to use Identity is to use Identit when creating a table.

1. Function Overview Keyspace notification allows clients to receive events that modify Rediskey changes in some way by subscribing to channels or patterns. All commands that modify key keys. All keys that received the LPUSHkeyvalue[value…] command. All expired keys in the db database. Events are distributed through Redis's subscription and publishing functions (pub/sub), so all clients that support subscription and publishing functions can directly use the keyspace notification function without any modifications. Because the current subscription and publishing functions of Redis adopt a fireandforget strategy, if your program

chm is converted to txt by using online conversion tools, using browser plug-ins, using command line tools and using third-party software. Detailed introduction: 1. Use the online conversion tool, just upload the CHM file, select the TXT format, and then download the converted TXT file; 2. Use the browser plug-in, after installing the plug-in, just open the CHM file in the browser, and then Click the plug-in button to convert CHM files into TXT format; 3. Use command line tools, etc.

Problems encountered: During the development process, you will encounter keys that need to be deleted in batches according to certain rules, such as login_logID (ID is a variable). Now you need to delete data such as "login_log*", but redis itself only has batch query. Command keys for class key values, but there is no command for batch deletion of a certain class. Solution: Query first, then delete, use xargs to pass parameters (xargs can convert pipe or standard input (stdin) data into command line parameters), execute the query statement first, and then remove the queried key value and the original del parameters. delete. redis-cliKEYSkey* (search condition)|xargsr

An unpatchable Yubico two-factor authentication key vulnerability has broken the security of most Yubikey 5, Security Key, and YubiHSM 2FA devices. The Feitian A22 JavaCard and other devices using Infineon SLB96xx series TPMs are also vulnerable.All

Pandas is a data analysis tool for Python, especially suitable for cleaning, processing and analyzing data. During the data analysis process, we often need to read data files in various formats, such as Txt files. However, some problems will be encountered during the specific operation. This article will introduce answers to common questions about reading txt files with pandas and provide corresponding code examples. Question 1: How to read txt file? txt files can be read using the read_csv() function of pandas. This is because
