123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace huoIdentify\controller;
- class AesEcb {
-
- private $key;
-
- private $cipher;
-
- private $ivlen;
-
- public function __construct($key, $cipher = 'aes-128-ecb') {
- $this->cipher = $cipher;
- $this->key = $key;
- }
-
- public function decrypt($cipherText) {
- return openssl_decrypt($cipherText, $this->cipher, $this->key, OPENSSL_RAW_DATA);
- }
-
- public function encrypt($plainText) {
- $result = openssl_encrypt($plainText, $this->cipher, $this->key, OPENSSL_RAW_DATA);
- return bin2hex($result);
- }
- }
|