首页 > 其他 > 详细

Encryption

时间:2016-07-05 12:02:24      阅读:245      评论:0      收藏:0      [点我收藏+]

Encryption

Configuration

Before using Nova‘s encrypter, you should set the ENCRYPT_KEY option of your app/Config.php configuration file to a 32 character, random string. If this value is not properly set, all values encrypted by Nova will be insecure.

For an easy way to set an encryption key, navigate to your project directory and use php nova make:key in your console/terminal.

Basic Usage

Encrypting a value

You may encrypt a value using the Crypt facade. All encrypted values are encrypted using OpenSSL and the AES-256-CBC cipher. Furthermore, all encrypted values are signed with a message authentication code (MAC) to detect any modifications to the encrypted string.

use Crypt;

Crypt::encrypt($secret);

Decrypting a value

Of course, you may decrypt values using the decrypt method on the Crypt facade. If the value can not be properly decrypted, such as when the MAC is invalid, an Encryption\DecryptException will be thrown:

use Crypt;
use Encryption\DecryptException;

try {
    $decrypted = Crypt::decrypt($encryptedValue);
} catch (DecryptException $e) {
    //
}

Encryption

原文:http://www.cnblogs.com/chunguang/p/5642986.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!