-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.php
37 lines (32 loc) · 978 Bytes
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace example;
use FreshLi\Rsa\RSAGenerate;
use FreshLi\Rsa\Provider;
class Example{
public function login()
{
$serverProvider = new Provider(['private_key' =>$_SESSION['private_key']]);
$password = $serverProvider->decodePublicEncode($password);
var_dump($password);
//todo: do login
}
public function getPublicKey()
{
$rsaGenerate = new RSAGenerate();
$publicKey = $rsaGenerate->getPublicKey();
$_SESSION['private_key'] = $rsaGenerate->getPrivateKey();
echo json_encode(['publicKey'=>$publicKey]);
}
public function test()
{
$rsa = new RSAGenerate();
$publicKey = $rsa->getPublicKey();
$privateKey = $rsa->getPrivateKey();
$serverProvider = new Provider(['public_key'=>$publicKey,'private_key'=>$privateKey]);
$pass = $serverProvider->publicKeyEncode('12345');
$pass = $serverProvider->decodePublicEncode($pass);
echo $pass;
}
}
$example = new Example();
$example->test(); //12345