talentrydev / cryptography
PHP library for encryption
Installs: 2 872
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Forks: 0
pkg:composer/talentrydev/cryptography
Requires
- php: ^8.3
- talentrydev/error-handling: ^3.0.0
Requires (Dev)
- phpunit/phpunit: ^11
- squizlabs/php_codesniffer: ^3.7
README
This is a thin library for encrypting and decrypting strings and generating hashes.
Installing
- Run:
composer require talentrydev/cryptography
Usage example
Encryption / decryption
$factory = new \Talentry\Cryptography\Factory\EncryptionServiceFactory();
$encryptionKey = $factory->generateEncryptionKey();
$service = $factory->generateEncryptionService($encryptionKey);
$encryptedString = $service->encrypt('secret');
$decryptedString = $service->decrypt($encryptedString);
WARNING: encrypt method is not idempotent. Calling it multiple times with the same input will return different outputs.
The only guarantee is that decrypting the encrypted string will always return the original (unencrypted) string.
Generate hash
$factory = new \Talentry\Cryptography\Factory\HashGeneratorFactory();
$hash = $factory->generate('input');
Development
- Install dependencies:
make deps - Run tests:
make test