Streamline Your Data Security: 'encryptToIPFS' with Lit Protocol

Streamline Your Data Security: 'encryptToIPFS' with Lit Protocol

We are excited to announce a feature that will make it even easier for developers to securely store and share their data on InterPlanetary File System (IPFS) using the Lit TS SDK. With the encryptToIPFS method, you can now easily encrypt and upload your data to IPFS, all with just a few lines of code.

With this feature, you no longer need to encrypt with Lit and then separately upload to IPFS. This method takes care of the entire process for you, allowing you to focus on your core application logic.

Note: The encryptToIpfs function internally uses the ipfs-http-client which requires the Infura Project ID & API Secret Key.

For encrypting a string, the code looks like so:

async encrypt() {
    const ipfsCid = await LitJsSdk.encryptToIpfs({
      authSig,
      accessControlConditions,
      chain,
      string: "Encrypt & store on IPFS seamlessly with Lit 😎",
      litNodeClient: this.litNodeClient,
      infuraId: 'YOUR INFURA PROJECT ID',
      infuraSecretKey: 'YOUR INFURA API-SECRET-KEY',
    });
}

For encrypting a file, replace string: with file: and pass in a file.

For decrypting:

async decrypt(ipfsCid) {
    const decryptedString = await LitJsSdk.decryptFromIpfs({
      authSig,
      ipfsCid, // This is returned from the above encryption
      litNodeClient: this.litNodeClient,
    });
}

You will get the decrypted string as an ArrayBuffer, for a decrypted file it will be a Uint8Array.

The encryptToIPFS method is available now, and we encourage you to try it out. Read about it in the docs here.
We believe that this new feature will make it easier than ever to securely store and share your data. If you have any questions reach out on Discord!