PHP code example of aldemco / secrets
1. Go to this page and download the library: Download aldemco/secrets library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
aldemco / secrets example snippets
return [
'table' => 'secrets',
'auto_clearing' => false,
'auto_clearing_dayly_at' => '01:00',
'length' => 6,
'secret_generator' => Aldemco\Secrets\SecretGenerator::class,
'secret_hasher' => Aldemco\Secrets\SecretHasher::class,
'is_crypt' => false,
'attemps' => 3,
'store_until_minutes' => 50000,
'valid_until_minutes' => 10,
'valid_from_minutes' => 0,
'multiple_limit' => 10,
];
use Aldemco\Secrets\Secrets;
/**
* Full
*/
Secrets::create(
context:'Verify',
contextId: null,
owner: 'User',
ownerId: 1 )
->length(6)
->setStoreUntil(Carbon\Carbon::now()->addDay(1))
->setValidUntil(Carbon\Carbon::now()->addMinutes(10))
->setAttemps(5)
->withInterval(60)
->genSecretStr(new Aldemco\Secrets\SecretGenerator)
->genCustomSecret(function(){
return \Str::UUID()->toString();
})
->encrypt(new Aldemco\Secrets\SecretHasher)
->save();
/**
* Minimal
*/
Secrets::create()->save();
use Aldemco\Secrets\Secrets;
/**
* Full
*/
Secrets::check(
inputSecret: '112544',
context:'Verify',
owner: 'User',
ownerId: 1)
->setEncrypt(new Aldemco\Secrets\SecretHasher)
->setUnlimitedAttemps()
->allowMultiple()
->setDissalowSuccessTimestamp()
->setUnlimitedAttemps()
->removeOnSuccess()
->verify()
->getResult();
/**
* Minimal
*/
Secrets::check(inputSecret: '112544')->verify();
bash
php artisan vendor:publish --tag="secrets-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="secrets-config"
bash
php artisan secrets:clear {select} {context?}