docs: Encryption.

This commit is contained in:
Hayden Young 2025-03-09 19:33:04 +01:00
parent 6f3b605174
commit 57204b1bae
2 changed files with 45 additions and 0 deletions

43
docs/ENCRYPTION.md Normal file
View File

@ -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
```

View File

@ -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.