mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-10-07 22:57:07 +00:00
docs: Encryption.
This commit is contained in:
parent
6f3b605174
commit
57204b1bae
43
docs/ENCRYPTION.md
Normal file
43
docs/ENCRYPTION.md
Normal 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
|
||||
```
|
||||
@ -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.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user