1: | <?php |
2: | |
3: | namespace IPay\Encryption; |
4: | |
5: | use phpseclib\Crypt\RSA; |
6: | |
7: | final class Encryptor |
8: | { |
9: | private const IPAY_PUBLIC_KEY = <<<PUBLIC |
10: | -----BEGIN PUBLIC KEY----- |
11: | MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDLenQHmHpaqYX4IrRVM8H1uB21 |
12: | xWuY+clsvn79pMUYR2KwIEfeHcnZFFshjDs3D2ae4KprjkOFZPYzEWzakg2nOIUV |
13: | WO+Q6RlAU1+1fxgTvEXi4z7yi+n0Zs0puOycrm8i67jsQfHi+HgdMxCaKzHvbECr |
14: | +JWnLxnEl6615hEeMQIDAQAB |
15: | -----END PUBLIC KEY----- |
16: | PUBLIC; |
17: | |
18: | public static function encrypt(string $message): string |
19: | { |
20: | $rsa = new RSA(); |
21: | $rsa->loadKey(static::IPAY_PUBLIC_KEY); |
22: | |
23: | return base64_encode($rsa->encrypt($message)); |
24: | } |
25: | } |
26: | |