From 57204b1bae27ec04a88aa3cde49fa79b69d81cd9 Mon Sep 17 00:00:00 2001 From: Hayden Young Date: Sun, 9 Mar 2025 19:33:04 +0100 Subject: [PATCH] docs: Encryption. --- docs/ENCRYPTION.md | 43 +++++++++++++++++++++++++++++++++++++++++ docs/GETTING_STARTED.md | 2 ++ 2 files changed, 45 insertions(+) create mode 100644 docs/ENCRYPTION.md diff --git a/docs/ENCRYPTION.md b/docs/ENCRYPTION.md new file mode 100644 index 0000000..f83d610 --- /dev/null +++ b/docs/ENCRYPTION.md @@ -0,0 +1,43 @@ +# Encryption + +OrbitDB features a modular architecture for database encryption. By passing a module to an OrbitDB database, different encryption methods can be employed. + +## Encrypting Databases + +OrbitDB provides a simple password-based encryption module called SimpleEncryption. To implement encryption, initiate SimpleEncryption and pass it when opening your database: + +```js +import { SimpleEncryption } from '@orbitdb/simple-encryption' + +const replication = await SimpleEncryption({ password: 'hello' }) +const data = await SimpleEncryption({ password: 'world' }) + +const encryption = { data, replication } + +const db = await orbitdb.open(dbNameOrAddress, { encryption }) +``` + +If you wish to use another encryption type, simply replace SimpleEncryption with the module of your choice. + +## Custom Encryption + +To implement a custom encryption module for OrbitDB, expose encrypt and decrypt functions: + +``` +const CustomEncryption = async () => { + const encrypt = (value) => { + // return encrypted value + } + + const decrypt = (value) => { + // return decrypted value + } + + return { + encrypt, + decrypt + } +} + +export default CustomEncryption +``` \ No newline at end of file diff --git a/docs/GETTING_STARTED.md b/docs/GETTING_STARTED.md index ee75840..810029b 100644 --- a/docs/GETTING_STARTED.md +++ b/docs/GETTING_STARTED.md @@ -307,3 +307,5 @@ These kinds of connectivity configurations are beyond the scope of OrbitDB. To f [Databases](./DATABASES.md) covers database management and data entry in more detail. [Replication](./REPLICATION.md) provides a comprehensive overview of how to perform data replication across multiple peers. + +[Replication](./ENCRYPTION.md) discusses database encryption using OrbitDB's modular architecture.