Skip to content

Latest commit

 

History

History
68 lines (41 loc) · 2.78 KB

README.md

File metadata and controls

68 lines (41 loc) · 2.78 KB

OrbitDB Simple Encryption

Matrix npm (scoped) node-current (scoped)

A simple password encryption module that encrypts data using AES-GCM PBKDF2.

NOTE This encryption module is not audited in any way for security and is intended for demonstration purposes only.

Install

This project uses npm and nodejs.

npm i @orbitdb/simple-encryption

Usage

To implement encryption within your database, create an encryption object and pass it to OrbitDB's open function:

import { createOrbitDB } from '@orbitdb/core'
import { SimpleEncryption } from '@orbitdb/simple-encryption'


// Instantiate encryption for either data, replication or both.
const replication = await SimpleEncryption({ password: 'hello' })
const data = await SimpleEncryption({ password: 'world' })

const encryption = { data, replication }

// Set up OrbitDB. See https://github.com/orbitdb/orbitdb/blob/main/docs/GETTING_STARTED.md for more information if you are unfamiliar with OrbitDB.
const db = await orbitdb.open('db-encrypted', { encryption })

When replicating a database, initiate the same encryption configuration and pass it to open:

import { createOrbitDB } from '@orbitdb/core'
import { SimpleEncryption } from '@orbitdb/simple-encryption' 


// Instantiate encryption for either data, replication or both.
const replication = await SimpleEncryption({ password: 'hello' })
const data = await SimpleEncryption({ password: 'world' })

const encryption = { data, replication }

const dbAddress = '0x0' // the address of the remote database. 

// Set up OrbitDB. See https://github.com/orbitdb/orbitdb/blob/main/docs/GETTING_STARTED.md for more information if you are unfamiliar with OrbitDB.
const db = await orbitdb.open(dbAddress, { encryption })

Contributing

Take a look at our organization-wide Contributing Guide. You'll find most of your questions answered there. Some questions may be answered in the FAQ, as well.

If you want to code but don't know where to start, check out the issues labelled "help wanted".

License

MIT OrbitDB Community