RESOURCES

Node.js SDK

SDK to integrate Phase in server-side applications running Node.js.

The Node.js SDK allows you to encrypt data server-side, as well as decrypt data.


Install the SDK

The Node.js SDK is distributed via npm. You can install it using the following command for your preferred package manager.

Install

npm i @phase.dev/phase-node

Import the SDK

Once installed, you can import the Node.js SDK into your project.

const Phase = require('@phase.dev/phase-node')

Initialize the SDK

Initialize the SDK with your APP_ID and APP_SECRET.

const phase = new Phase(APP_ID, APP_SECRET)

Usage

Encrypt

The encrypt API allows you to encrypt data. It returns a Promise that resolves in a encrypted string in the Phase Ciphertext format, so you need to await it.

const ciphertext = await phase.encrypt('hello world')

Decrypt

The decrypt API allows you to decrypt a Phase Ciphertext string. It returns a Promise that resolves in a plaintext string, so you need to await it.

const plaintext = await phase.decrypt(ciphertext)