· 5 years ago · Oct 09, 2020, 11:38 AM
1 //JS
2 return new Promise((resolve, reject) => {
3
4 let data = {
5
6 'email': payload.email,
7 'password': payload.password
8
9 }
10
11 var crypt = new JSEncrypt();
12 crypt.setPublicKey(PUBLIC_KEY.default);
13 var secretKey = crypt.encrypt(data);
14 resolve(secretKey);
15 })
16
17
18 //php
19 public function decryptRSA($string)
20 {
21 $decryptString = $this->decryptBase64($string);
22 $private_key = file_get_contents('...path to privatekey');
23 $data = openssl_get_privatekey($private_key);
24 if(openssl_private_decrypt($decryptString, $response, $private_key)){
25 return $response;
26 }
27 else
28 {
29 return "Ошибка ключа";
30 }
31 }