Skip to content

Instantly share code, notes, and snippets.

View coding-island-js's full-sized avatar

codingraj coding-island-js

View GitHub Profile
@SuaYoo
SuaYoo / web3-storage.js
Last active November 22, 2021 16:15
Encrypt and decrypt JSON files for Web3 Storage (requires Node.js >=15.7)
// node >=15.7.0 required for Blob usage
const { Blob } = require('buffer');
const crypto = require('crypto');
const { Web3Storage } = require('web3.storage');
// Secret env variables
//
// Grab token from https://web3.storage/tokens/
const WEB3_STORAGE_API_KEY = 'my_api_key';
// Encryption secret must have exact length of 32