rafrsr / crypto
PHP中简单加密和解密字符串。
2.1.4
2019-09-12 16:53 UTC
Requires
- php: >=5.4
Requires (Dev)
- phpunit/phpunit: 4.1.*
- satooshi/php-coveralls: ~1.0
- toplib/coding-standard: dev-master
README
PHP中简单加密和解密字符串。
特性
- 简单使用
Crypto::build('secretKey')->encrypt('secret message')
- 支持最流行的MCRYPT算法
- 通过
isEncrypted($data)
方法进行加密验证 - 防止重复加密/解密
用法
use Rafrsr\Crypto\Crypto; $encryptor = Crypto::build('JH83UN177772JJASHGAGG38UABASDSD'); //$encryptor = Crypto::build('JH83UN177772JJASHGAGG38UABASDSD', MCRYPT_RIJNDAEL_128); //using specific algorithm $secret = $encryptor->encrypt('This is a secret message'); if ($encryptor->isEncrypted($secret)) { echo 'The messages is encrypted'; } $notSecret = $encryptor->decrypt($secret); if (!$encryptor->isEncrypted($notSecret)) { echo 'The message is not encrypted'; }