title: How to send encrypted text from node js and decrypt in typescript?
body: <p>I am making firebase cloud function in node.js inside <code>index.js</code> file as,</p>
  
  <pre><code>exports.calculatePrice = functions.https.onRequest((request, response) =&gt; {
      cors(request, response, () =&gt; {
           var fare = 10; 
           response.send(request.query.distance * fare);
      })
  });
  </code></pre>
  
  <p>Here <code>response.send(request.query.distance * fare)</code> is the calculation for total fare based on the distance travelled and fare..</p>
  
  <p>Here i need to send this <code>response.send(request.query.distance * fare)</code> as secure data and need to receive it in typescript as,</p>
  
  <pre><code>let distance = 20;
  this.http.get('https://us-central1-sample-project.cloudfunctions.net/calculatePrice/?distance=' + distance).subscribe(data =&gt; {
      this.finalFare = data;
  })
  </code></pre>
  
  <p>I also need to send the <code>distance</code> with encrypted in typescript and get the encrypted value and need to make decrypted in <code>node js</code>..</p>
  
  <p>In simple while fetching the data in <code>this.http.get(https://us-central1-sample-......)</code> in which i need to pass the encrypted distance and need to get it in <code>index.js</code> and after calculation of total fare was done need to send back the total fare with encryption and need to get the total fare in <code>home.ts</code> (typescript file) decrypted and assigned to <code>this.finalFare = data</code>..</p>
  
  <p>I have tried the below in <code>index.js</code> inside <code>calculatePrice</code> function by importing <code>crypto</code>,</p>
  
  <pre><code>var salt = crypto.randomBytes(128).toString('base64');
  var iterations = 10000;
  var hash = pbkdf2(String(request.query.distance * fare), salt, iterations);
  
  response.send(hash).
  </code></pre>
  
  <p>But it doesn't work..</p>
  
  <p>I hope even it would be better to replace the word encrypt and decrypt (which i have used in this question) with sending and receiving the secure data (which is all i am in the need)..</p>
  
  <p>Please help me to send and receive the data securely from node js to typescript (for calculated total price) and also from typescript to node js (for distance)..</p>