https://github.com/eiblybrasil/php-crypt
A simple php class for encryption.
https://github.com/eiblybrasil/php-crypt
class cryptography php php72 php73 php74 php80 php81
Last synced: 6 days ago
JSON representation
A simple php class for encryption.
- Host: GitHub
- URL: https://github.com/eiblybrasil/php-crypt
- Owner: eiblybrasil
- License: apache-2.0
- Created: 2022-05-13T03:07:21.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-05-20T20:59:03.000Z (over 3 years ago)
- Last Synced: 2025-07-20T15:24:44.699Z (7 months ago)
- Topics: class, cryptography, php, php72, php73, php74, php80, php81
- Language: PHP
- Homepage:
- Size: 28.3 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Using
```php
encrypt("content");
// Result: $value = MDI2NTYwYTM5N2FiZWY0MDRmM2I5ZDU2OTM5OTg!NmRiZTYVZAuvIFt2Xm@eVug0eN)!A
// function decrypt(string $string): ?string
$decrypted_value = $crypt->decrypt($value);
// Result: $decrypted_value = content
```
## Warnings:
By default the salt mode will be used, but be careful.
When running the first time, it will create a json file with an array of salts.
Once stored, it will be used to decrypt. Be aware that deleting the file will make it impossible to decrypt the string in the future.
## Functions
```php
function setSaltStatus(bool $salt): void {...}
function getSaltStatus(): bool {...}
function setHash(string $hash): void {...}
function getHash(): string {...}
function setKey(string $key): void {...}
function getKey(): string {...}
function setMethod(string $method): void {...}
function getMethod(): string {...}
function doGenerateSalts(int $c = 16, int $l = 8): array {...}
function doGenerateSalt(int $len = 8): array {...}
function encrypt(string $string): string {...}
function decrypt(string $string): ?string {...}
```