· 7 years ago · Dec 11, 2018, 07:14 AM
1const exec_php = require('exec-php');
2
3exec_php(__dirname + '/auth.php', "c:/xampp/php/php.exe", (error, php, output) =>
4{
5 console.error('php error', error);
6 console.log('php', php);
7 console.log('php output', output);
8});
9
10<?php
11 $encrypt_method = "AES-256-CBC";
12 $secret_key = '';
13 $secret_iv = '';
14
15 function encrypt($string) {
16 echo "asdfg";
17 $output = false;
18 $key = hash('sha256', $this->secret_key);
19 $iv = substr(hash('sha256', $this->secret_iv), 0, 16);
20 $output = openssl_encrypt($string, $this->encrypt_method, $key, 0, $iv);
21 $output = base64_encode($output);
22 return "dsdf";
23 }
24
25 function decrypt($string) {
26 $output = false;
27 $key = hash('sha256', $this->secret_key);
28 $iv = substr(hash('sha256', $this->secret_iv), 0, 16);
29 $output = openssl_decrypt(base64_decode($string), $this->encrypt_method, $key, 0, $iv);
30 return $output;
31 }
32?>