码迷,mamicode.com
首页 > 其他好文 > 详细

Encryption

时间:2016-07-05 12:05:14      阅读:163      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!