Skip to content
赞助商赞助商
Your logo here
Your logo here
Your logo here
Your logo here
Your logo here
Your logo here
Your logo here
Your logo here
Your logo here
Your logo here
Your logo here
Your logo here
Your logo here
Your logo here
Your logo here
Your logo here

Encryption

Introduction

Laravel provides facilities for strong AES encryption via the Mcrypt PHP extension.

Basic Usage

Encrypting A Value

php
$encrypted = Crypt::encrypt('secret');

NOTE

Be sure to set a 16, 24, or 32 character random string in the key option of the config/app.php file. Otherwise, encrypted values will not be secure.

Decrypting A Value

php
$decrypted = Crypt::decrypt($encryptedValue);

Setting The Cipher & Mode

You may also set the cipher and mode used by the encrypter:

php
Crypt::setMode('ctr');

Crypt::setCipher($cipher);