ipfssenc

package module
v0.0.0-...-66ab4c0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2020 License: MIT Imports: 10 Imported by: 1

README

ipfs-senc - simple private file sharing on ipfs.

WARNING: NOT AUDITED! USE AT OWN RISK. DONT USE FOR ANYTHING SERIOUS.

Currently, IPFS does not have an inbuilt content encryption system. Many solutions exist on top. I wanted something easy. This builds on senc.

View examples on the web

See the viewer webapp docs here

On the commandline

This tool is command-line based.

Install

Using go get:

go get github.com/ipfs-shipyard/ipfs-senc/ipfs-senc
How to encrypt & share
# encrypt with a known key. (256bits please)
ipfs-senc share --key <secret-key> <path-to-file-or-directory>

# encrypt with a randomly generated key. will be printed out.
ipfs-senc share <path-to-file-or-directory>

Leave your IPFS node running, or pin this somewhere. consider ipfs-cluster.

How to download & decrypt
# will ask for key
ipfs-senc download <ipfs-link> <local-source-dir-or-file>

# decrypt with given key.
ipfs-senc download --key <secret-key> <ipfs-link> [<local-destination-dir>]

Will use your local ipfs node, or the ipfs-gateway if no local node is available.

Shell Script

If you have the senc tool, then you can also use the script provided in ipfs-senc/ipfs-senc.sh

On the browser

This can work entirely on the browser. The viewer code is included in this repo. It needs to learn how to add files too. (drag-it, drop-it, crypt-it, pin-it, share-it, click-it, load-it, de-crypt, view-it).

License

MIT, copyright Protocol Labs, Inc.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotImplemented       = errors.New("ErrNotImplemented")
	ErrFailedToUseLocalNode = errors.New("Failed to use local node")
)
View Source
var (
	GlobalNodeURL    = "https://gateway.ipfs.io:4001"
	GlobalGatewayURL = "https://gateway.ipfs.io"
	LocalNodeURL     = "http://localhost:4001"
	LocalGatewayURL  = "http://localhost:8080"
)

Functions

func Bundle

func Bundle(localPath string, wrapDir bool) (bundle io.Reader, err error)

Bundle groups all the contents of a given localPath into a TarBall

func Decrypt

func Decrypt(ct io.Reader, secret Key) (pt io.Reader, err error)

Decrypt decrypts a given CipherText w/ given Key.

func Encrypt

func Encrypt(pt io.Reader, secret Key) (ct io.Reader, err error)

Encrypt encrypts a given PlainText w/ given Key.

func Get

func Get(n *ipfs.Shell, link IPFSLink) (io.ReadCloser, error)

Get retrieves a CipherText for given Link from the network.

func GetDecryptAndUnbundle

func GetDecryptAndUnbundle(n *ipfs.Shell, link IPFSLink, localPath string, secret Key) error

func GetROIPFSNode

func GetROIPFSNode(url string) *ipfs.Shell

func GetRWIPFSNode

func GetRWIPFSNode(url string) (*ipfs.Shell, error)

func TarAndZip

func TarAndZip(src string, wrapDir bool, writers ...io.Writer) error

from: https://medium.com/@skdomino/taring-untaring-files-in-go-6b07cf56bc07

TarAndZip takes a source and variable writers and walks 'source' writing each file found to the tar writer; the purpose for accepting multiple writers is to allow for multiple outputs (for example a file, or md5 hash)

func Unbundle

func Unbundle(bundle io.Reader, localPath string) error

Unbundle all contents of a bundle into a localPath

func UnzipAndUntar

func UnzipAndUntar(dst string, r io.Reader) error

UnzipAndUntar takes a destination path and a reader; a tar reader loops over the tarfile creating the file structure at 'dst' along the way, and writing any files

Types

type IPFSLink string

func BundleEncryptAndPut

func BundleEncryptAndPut(n *ipfs.Shell, localPath string, secret Key, wrapDir bool) (IPFSLink, error)

func Put

func Put(n *ipfs.Shell, r io.Reader) (IPFSLink, error)

Put adds a given Reader to the network, and gets a link for it.

type Key

type Key []byte

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL