Mahmoud Al-HabashOpen to new projects
  • WorkWork
  • ServicesServices
  • LabLab
  • WritingWriting
  • ContactContact
Amman--:--عربي
Writing/Laravel

Laravel Encryption and Hashing

Secure sensitive data with encryption and hashing.

16 January 20261 min readLaravelاقرأ بالعربية

On this page

  1. Encrypt/Decrypt
  2. Model Encryption
  3. Hashing
  4. Password Validation

Security with encryption:

Encrypt/Decrypt

php
$encrypted = Crypt::encrypt($value);
$decrypted = Crypt::decrypt($encrypted);

Model Encryption

php
protected $casts = [
    'secret' => 'encrypted',
];

Hashing

php
$hashed = Hash::make('password');
Hash::check('password', $hashed);

Password Validation

php
'password' => [
    'required',
    Password::min(8)
        ->letters()
        ->mixedCase()
        ->numbers()
        ->symbols(),
]
All articles

Keep reading

  • Laravel Action Classes Pattern16 January 20261 min read
  • Laravel Action Classes: Single Responsibility16 January 20261 min read
  • Laravel API Rate Limiting16 January 20261 min read