Skip to content

Commit f529678

Browse files
committed
docs(readme): fix quick example to match real crypto service contract
1 parent e8ec8dc commit f529678

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Latest Version](https://img.shields.io/packagist/v/maatify/crypto.svg?style=for-the-badge)](https://packagist.org/packages/maatify/crypto)
44
[![PHP Version](https://img.shields.io/packagist/php-v/maatify/crypto.svg?style=for-the-badge)](https://packagist.org/packages/maatify/crypto)
5-
[![License](https://img.shields.io/packagist/l/maatify/crypto.svg?style=for-the-badge)](LICENSE)
5+
[![License](https://img.shields.io/github/license/Maatify/crypto?style=for-the-badge)](LICENSE)
66

77
![PHPStan](https://img.shields.io/badge/PHPStan-Level%20Max-4E8CAE)
88

@@ -33,14 +33,25 @@ composer require maatify/crypto
3333

3434
```php
3535
use Maatify\Crypto\DX\CryptoProvider;
36+
use Maatify\Crypto\Reversible\DTO\ReversibleCryptoMetadataDTO;
3637
3738
$crypto = $container->get(CryptoProvider::class);
3839
3940
$service = $crypto->context("user:email:v1");
4041
41-
$cipher = $service->encrypt("hello world");
42+
$encrypted = $service->encrypt("hello world");
4243
43-
$plain = $service->decrypt($cipher);
44+
$metadata = new ReversibleCryptoMetadataDTO(
45+
$encrypted['result']->iv,
46+
$encrypted['result']->tag
47+
);
48+
49+
$plain = $service->decrypt(
50+
$encrypted['result']->cipher,
51+
$encrypted['key_id'],
52+
$encrypted['algorithm'],
53+
$metadata
54+
);
4455
```
4556

4657
---

0 commit comments

Comments
 (0)