colly_wyx
2018-04-23 0d64b5ae5fb9c6d2f692d55dfabce78b300a521a
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
<?php
/**
 * PhalApi_Crypt_RSA_KeyGenerator 生成器
 * 
 * RSA私钥或公钥的生成器
 *
 * @package     PhalApi\Crypt\RSA
 * @license     http://www.phalapi.net/license GPL 协议
 * @link        http://www.phalapi.net/
 * @author      dogstar <chanzonghuang@gmail.com> 2015-03-15
 */
 
class PhalApi_Crypt_RSA_KeyGenerator {
 
    protected $privkey;
 
    protected $pubkey;
 
    public function __construct() {
        $res = openssl_pkey_new();
        openssl_pkey_export($res, $privkey);
        $this->privkey = $privkey;
 
        $pubkey = openssl_pkey_get_details($res);
        $this->pubkey = $pubkey['key'];
    }
 
    public function getPriKey() {
        return $this->privkey;
    }
 
    public function getPubKey() {
        return $this->pubkey;
    }
}