Files
ave-cms/help/en/helpers/Crypt.md
T
2026-07-27 12:58:44 +03:00

1.1 KiB

Crypt - string encryption

App\Helpers\Crypt - reversible string encryption and minor conversions.

use App\Helpers\Crypt;

Methods

_crypt($string) / _decrypt($string)

Encrypt/decrypt a string (pair operations).

$token = Crypt::_crypt($payload);
$data  = Crypt::_decrypt($token);   // исходное значение

###crc32($value) CRC32 hash of the value (fast checksum, not for security).

$key = 'cache_' . Crypt::crc32($sql);

###convert64b32($int) Number base conversion (64 ↔ 32) - for compact identifiers.


When to use what

Problem Tool
Reversibly hide value (token, payload) Crypt::_crypt() / _decrypt()
String hash (comparison, cache key) Str::sha256() / Crypt::crc32()
Passwords password_hash() / password_verify() - not Crypt
Signature/comparison of secrets Str::equals() (timing-safe)

_crypt/_decrypt are suitable for service data, but this is not a replacement for a full-fledged encryption of secrets at the infrastructure level.