colly_wyx
2018-06-14 12690729bc3f0a3e920051e11d2f5522a15f44bc
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;
    }
}