|
|
@@ -185,4 +185,41 @@ class Award extends Controller
|
|
|
header("Pragma: no-cache");
|
|
|
$objWriter->save('php://output');
|
|
|
}
|
|
|
+
|
|
|
+ public function dataEncode() {
|
|
|
+
|
|
|
+ $orders = $this->app->db->name('Order')->select();
|
|
|
+
|
|
|
+ foreach ($orders as $order) {
|
|
|
+
|
|
|
+ $name = $this->dataEncrypt($order['name']);
|
|
|
+ $mobile = $this->dataEncrypt($order['mobile']);
|
|
|
+ $address = $this->dataEncrypt($order['address']);
|
|
|
+
|
|
|
+ if (strlen($name) > 15) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->app->db->name('Order')->where('id', $order['id'])->update([
|
|
|
+ 'name' => $name,
|
|
|
+ 'mobile' => $mobile,
|
|
|
+ 'address' => $address
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success('加密成功');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function dataEncrypt($str)
|
|
|
+ {
|
|
|
+ $aesKey = "sinaVideo1234";
|
|
|
+ $data = openssl_encrypt($str, 'AES-128-ECB', $aesKey, OPENSSL_RAW_DATA);
|
|
|
+ return base64_encode($data);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function dataDecrypt($str)
|
|
|
+ {
|
|
|
+ $aesKey = "sinaVideo1234";
|
|
|
+ return openssl_decrypt(base64_decode($str), 'AES-128-ECB', $aesKey, OPENSSL_RAW_DATA);
|
|
|
+ }
|
|
|
}
|