Version 0.7.0 #1
9
app/Contracts/CryptographyContract.php
Normal file
9
app/Contracts/CryptographyContract.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
interface CryptographyContract
|
||||
{
|
||||
public function encrypt(string $text): string;
|
||||
public function decrypt(string $encryptedText): string;
|
||||
}
|
@ -10,8 +10,10 @@ use App\Captcha\Images\Body;
|
||||
use App\Captcha\Images\Head;
|
||||
use App\Captcha\Images\ImageManager;
|
||||
use App\Captcha\Images\Lines;
|
||||
use App\Contracts\CryptographyContract;
|
||||
use App\Services\Api\V1\CaptchaGenerateService;
|
||||
use App\Services\CaptchaToken\CaptchaTokenHandler;
|
||||
use App\Services\CryptographyString;
|
||||
use App\Services\GenerateTokenCommand\GenerateTokenUlidCommand;
|
||||
use App\Services\GenerateTokenCommand\GenerateTokenUuidCommand;
|
||||
use App\Services\Search\CreateSearchInstanceCommand;
|
||||
@ -35,6 +37,8 @@ final class AppServiceProvider extends ServiceProvider
|
||||
$this->app->bind(ImageBody::class, Body::class);
|
||||
$this->app->bind(ImageLines::class, Lines::class);
|
||||
|
||||
$this->app->bind(CryptographyContract::class, CryptographyString::class);
|
||||
|
||||
$this->app->bind(CreateSearchInstanceCommand::class, function () {
|
||||
return new CreateSearchInstanceCommand(Search::class);
|
||||
});
|
||||
|
19
app/Services/CryptographyString.php
Normal file
19
app/Services/CryptographyString.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Contracts\CryptographyContract;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
|
||||
final class CryptographyString implements CryptographyContract
|
||||
{
|
||||
public function encrypt(string $text): string
|
||||
{
|
||||
return Crypt::encryptString($text);
|
||||
}
|
||||
|
||||
public function decrypt(string $encryptedText): string
|
||||
{
|
||||
return Crypt::decryptString($encryptedText);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user