npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ipfs-eth-encryption

v1.0.0

Published

Encrypt file using public ethereum keys, upload it to IPFS and decrypt it using the private key

Downloads

4

Readme

IPFS-ETH-ENCRYPTION

Store encrypted data on IPFS and control it with your Ethereum key pair. The package leverages eth-crypto for asymmetric encryption/decryption and ipfs-js

Install

npm install ipfs-eth-encryption

Setup

import {Encrypt, UploadToIpfs, Decrypt} from "ipfs-eth-encryption"
import * as IPFS from 'ipfs-core'

async function main() {
    // Instantiate an IPFS node
    const node = await IPFS.create();
}

Encrypt

const message = "Hello world!"

const publicKey = "32da4be1d1244fbb5c27ab9ff75723a7cd22fb13b0303017e30d377b88b611faa7dded7adc874452a811387e9c769dce09ec947b03e0490fa71c3b8f438be780"

const encrypted = await Encrypt(message, publicKey)

/* 
  iv: '45140d6fc370b7c70ae1d0128581d725',
  ephemPublicKey: '04500ee21c2a300a2733528fdb10f11af40054cfe62b40aed9c793868c4c940ac63fa6799b67358f2715b8f5baab0c5e56fe27cfd230bc6cb0f67bd4234f24ca51',
  ciphertext: 'aae1f5af5c06df1eef9ef6d071be54a3',
  mac: '6645de4efaa603693eb2869af4641ec123d88eb93f2f80caa7a0f18a21b045c8'
*/

Encrypt a message to a publicKey:

Upload to IPFS

const node = await IPFS.create();

const cid = await UploadToIpfs(encrypted, node)
// QmSfHEFgrbTaF9Xm2UCGtf8T8wstCDArwA5za6ZX84fd6q

Fetch data from IPFS and Decrypt

const node = await IPFS.create();

const privateKey = "0xd855f906bf500f14ad028ddb9ca6026d43f072ea759f5f870017edf504d3f6b0"

const decrypted = await Decrypt(privateKey, cid, node)
// Hello world!
  • To decrypt a file you need to use the privateKey that corresponds to the publicKey used to encrypt the message