mblsolutions / mcryptgatewayservice
允许与MBL Solutions Mcrypt Gateway进行交互的软件包
v1.2.0
2020-09-28 14:39 UTC
Requires
- php: >=7.1.0
- ext-json: *
- guzzlehttp/guzzle: ^6.3|^7.0
Requires (Dev)
- phpunit/phpunit: ~7.0
- vlucas/phpdotenv: ~2.0
README
与MBL Solutions Mcrypt Gateway Service交互的软件包。
允许不支持mcrypt_encrypt和mcrypt_decrypt的PHP版本处理Mcrypt加密和解密。
使用Composer安装
composer require mblsolutions/mcryptgatewayservice
使用方法
传入的数据应为base64编码
加密
$mcryptService = new MBLSolutions\McryptService('https://example.execute-api.eu-west-1.amazonaws.com', 'prod'); $string = base64_encode('password'); // Encrypted base64 encoded string `password` $secret = base64_encode('thisisatwentyfourcharkey'); // encryption secret $result = $mcryptService->encrypt($string, $secret); // Encrypts into 0sQg7vz6S9g=
解密
$mcryptService = new MBLSolutions\McryptService('https://example.execute-api.eu-west-1.amazonaws.com', 'prod'); $encrypted = '0sQg7vz6S9g='; // Encrypted base64 encoded string `password` $secret = base64_encode('thisisatwentyfourcharkey'); // encryption secret $result = $mcryptService->decrypt($encrypted, $secret); // Decrypts into cGFzc3dvcmQ= base64_decode($result); // password