Skip to content

lwl1989/RSA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RSA

一个PHP生成RSA加密和解密的包

###示例(example)

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;
	}
}

####author email:[email protected]

Releases

No releases published

Packages

No packages published

Languages