Usage
Encrypt Data

💳 Encrypt Data

Encrypting sensitive data is straightforward with Laravel Crypto. The package supports secure encryption using modern algorithms such as AES-256-CBC, ensuring the safety of your data.

Using the Facade

The Crypto facade provides a simple way to encrypt your data:

use Akira\LaravelCrypto\Facades\Crypto;
 
// Encrypt data
$encrypted = Crypto::encrypt('Your sensitive information');
 
// Output the encrypted string
echo $encrypted;

Using Dependency Injection

If you prefer using dependency injection, you can use the LaravelCrypto class directly:

 
use Akira\LaravelCrypto\LaravelCrypto;
 
public function encryptData(LaravelCrypto $crypto)
{
    // Encrypt data
    $encrypted = $crypto->encrypt('Your sensitive information');
 
    // Output the encrypted string
    echo $encrypted;
}

Customizing Encryption

You can customize the encryption key and algorithm before encrypting data:

use Akira\LaravelCrypto\Facades\Crypto;
 
// Set a custom encryption key
 
Crypto::setKey('your_custom_key');
 
// Set a custom encryption algorithm
 
Crypto::setAlgorithm('AES-128-CBC');
 
// Encrypt data
 
$encrypted = Crypto::encrypt('Your sensitive information');
 
// Output the encrypted string
 
echo $encrypted;