|
@@ -42,7 +42,7 @@ class OriginBank
|
|
|
$data['ord_name'] = "购买物品订单名称";
|
|
|
|
|
|
dump($data);
|
|
|
- $base_data['data'] = $this->encrypt2(json_encode($data),$this->open_key);
|
|
|
+ $base_data['data'] = $this->encrypt3(json_encode($data),$this->open_key);
|
|
|
dump($data);
|
|
|
|
|
|
dump($this->decrypt2($base_data['data'],$this->open_key));
|
|
@@ -108,6 +108,31 @@ class OriginBank
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
+ public function encrypt3($key, $iv, $data)
|
|
|
+ {
|
|
|
+ /**
|
|
|
+ * 打开加密
|
|
|
+ */
|
|
|
+ $td = @mcrypt_module_open(MCRYPT_RIJNDAEL_128, "", MCRYPT_MODE_CBC, "");
|
|
|
+ /**
|
|
|
+ * 初始化加密
|
|
|
+ */
|
|
|
+ @mcrypt_generic_init($td, $key, $iv);
|
|
|
+ /**
|
|
|
+ * 加密
|
|
|
+ */
|
|
|
+ $encrypted = @mcrypt_generic($td, $data);
|
|
|
+ /**
|
|
|
+ * 清理加密
|
|
|
+ */
|
|
|
+ @mcrypt_generic_deinit($td);
|
|
|
+ /**
|
|
|
+ * 关闭
|
|
|
+ */
|
|
|
+ @mcrypt_module_close($td);
|
|
|
+ return base64_encode($encrypted);
|
|
|
+ }
|
|
|
+
|
|
|
public function encrypt2($input, $key)
|
|
|
{
|
|
|
$data = openssl_encrypt($input, 'AES-128-ECB', $key, OPENSSL_RAW_DATA);
|