Skip to content

Commit 4281795

Browse files
committed
Update README.md
1 parent a8a131a commit 4281795

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,20 @@ use Rollerworks\Component\SplitToken\Argon2SplitTokenFactory;
6060
// the FakeSplitTokenFactory instead as cryptographic operations
6161
// can a little heavy.
6262

63-
$splitTokenFactory = new Argon2SplitTokenFactory();
63+
// Default configuration, shown here for clarity.
64+
$config = [
65+
'memory_cost' => \PASSWORD_ARGON2_DEFAULT_MEMORY_COST,
66+
'time_cost' => \PASSWORD_ARGON2_DEFAULT_TIME_COST,
67+
'threads' => \PASSWORD_ARGON2_DEFAULT_THREADS,
68+
];
69+
70+
// Either a DateInterval or a DateInterval parsable-string
71+
$defaultLifeTime = null;
72+
73+
$splitTokenFactory = new Argon2SplitTokenFactory(/*config: $config, */ $defaultLifeTime);
74+
75+
// Optionally set PSR/Clock compatible instance
76+
// $splitTokenFactory->setClock();
6477

6578
// Step 1. Create a new SplitToken for usage
6679

@@ -81,6 +94,7 @@ $authToken = $token->token(); // Returns a \ParagonIE\HiddenString\HiddenString
8194
// Indicate when the token must expire. Note that you need to clear the token from storage yourself.
8295
// Pass null (or leave this method call absent) to never expire the token (not recommended).
8396
//
97+
// If not provided uses "now" + $defaultLifeTime of the factory constructor.
8498
$authToken->expireAt(new \DateTimeImmutable('+1 hour'));
8599

86100
// Now to store the token cast the SplitToken to a SplitTokenValueHolder object.

0 commit comments

Comments
 (0)