IPFS File Encryption in NodeJS

IPFS is the InterPlanetary File System, it’s a protocol and peer-to-peer network for storing and sharing data in a distributed file system. IPFS uses content-addressing to uniquely identify each file in a global namespace connecting all computing devices.

Image for post
Image for post
encryption diagram

Recently I’ve implemented a sample project that allows us to encrypt/decrypt files for storing them on IPFS. Which is an ideal solution to hosting and securing any sensitive data.

Github project: https://github.com/healzer/ipfs-file-encryption

On my Github page I explain how to encrypt files prior to uploading them to IPFS. Similarly it can decrypt and download these files. The solution uses both RSA and AES encryption algorithms to achieve maximum security.


IPFS dominates over bittorrent in terms of availability and performance. Due to content-addressing it prevents file duplication.

Individual file(s) can be easily downloaded from some “source”; whereas with Bittorrent one has to create a “.torrent” file, submit it to tracker(s) and seed it.

IPFS on the other hand is much faster on making files available for sharing. IPFS files can be distributed and load-balanced, making it a perfect CDN solution. This isn’t possible with BitTorrent at all.

File-streaming works out of the box over HTTP in IPFS. Whereas streaming in BitTorrent is a paid feature.

Large files are being chunked/sharded in IPFS. So one can download chunks from different nodes and maximize bandwidth usage. This is both done in IPFS and BitTorrent.

BitTorrent has a high barrier to entry for new people trying to share files. Whereas IPFS easily integrates to a drag-and-drop interface.

With IPFS one chooses which files he/she wants to “seed”. While BitTorrent requires you to seed all files within the torrent.

BitTorrent clients did improve over the years,
it is possible to download file subsets,
and it may be possile to seed file subsets.

IPFS works over HTTP REST, whereas torrents only work over the BitTorrent protocol. This makes it harder for the community to build p2p apps/services/solutions.

Written by

Become a rockstar programmer and try to reach genius status on codr https://nevolin.be/codr/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store