Skip to content

Commit 46ddd21

Browse files
committed
fix readme
1 parent 30d5ec6 commit 46ddd21

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

README.md

+17-6
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,31 @@ Note, this library is still quite new (2021/07/02). It's quite likely to have ma
77

88
## Example usage
99

10+
The main functionality reflects legacy behaviour in PostfixAdmin with a 'pacrypt' function, which when given ...
11+
12+
* one argument - clear text password -> returns a hash.
13+
* two arguments - clear text password and stored hash -> if the return value matches the stored hash, then the clear text password was a match for the hash we have.
14+
1015
```PHP
11-
$tool = new \PostfixAdmin\PasswordHashing\Crypt();
16+
$tool = new \PostfixAdmin\PasswordHashing\Crypt('ARGON2I');
1217

1318
// should output something to indicate what your system supports (may be dependent on PHP variant, PHP modules etc)
14-
var_dump($tool->supportedMechanisms()); // e.g. MD5, SHA1, ARGON2I.
1519

16-
var_dump($tool->hash(Crypt::CLEARTEXT, 'fishbeans'));
20+
$hash = $tool->crypt('fishbeans');
1721

18-
var_dump($tool->hash(Crypt::MD5, 'fishbeans'));
22+
echo "Hash is : $hash \n";
1923

20-
var_dump($tool->verify(Crypt::MD5, 'fishbeans', 'some-hash'));
24+
echo "Verify : " . json_encode($hash == $tool->crypt('fishbeans', $hash)) . "\n";
25+
echo "Verify fails with : " . json_encode('cat' == $tool->crypt('fishbeans', $hash)) . "\n";
26+
27+
```
2128

22-
var_dump($tool->verify(Crypt::ARGON2I, 'fishbeans', 'some-hash'));
29+
the above code will output something similar to :
2330

31+
```text
32+
Hash is : {ARGON2I}$argon2i$v=19$m=65536,t=4,p=1$d1JMUXVHSUtLTGhxYnowVQ$4raz6DDUbtRysi+1ZTdNL3L5j4tcSYnzWxyLVDtFjKc
33+
Verify : true
34+
Verify fails with : false
2435
```
2536

2637

0 commit comments

Comments
 (0)