colly
2017-07-26 c1236314ef1122e14edd46c9fe4102fc16e2ce46
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
<?php
/**
 * PhalApi_Crypt_RSA_Pri2Pub RSA原始加密
 * 
 * RSA - 私钥加密,公钥解密
 *
 * @package     PhalApi\Crypt\RSA
 * @license     http://www.phalapi.net/license GPL 协议
 * @link        http://www.phalapi.net/
 * @author      dogstar <chanzonghuang@gmail.com> 2015-03-14
 */
 
class PhalApi_Crypt_RSA_Pri2Pub implements PhalApi_Crypt {
 
    public function encrypt($data, $prikey) {
        $rs = '';
 
        if (@openssl_private_encrypt($data, $rs, $prikey) === FALSE) {
            return NULL;
        }
 
        return $rs;
    }
 
    public function decrypt($data, $pubkey) {
        $rs = '';
 
        if (@openssl_public_decrypt($data, $rs, $pubkey) === FALSE) {
            return NULL;
        }
 
        return $rs;
    }
}