getEncryptSembastCodecSalsa20 function

SembastCodec getEncryptSembastCodecSalsa20({
  1. required String password,
})

Create a codec to use to open a database with encrypted stored data.

Hash (md5) of the password is used (but never stored) as a key to encrypt the data using the Salsa20 algorithm with a random (8 bytes) initial value

This is just used as a demonstration and should not be considered as a reference since its implementation (and storage format) might change.

No performance metrics has been made to check whether this is a viable solution for big databases.

The usage is then

Initialize the encryption codec with a user password
var codec = getEncryptSembastCodec(password: 'your_user_password');
Open the database with the codec
Database db = await factory.openDatabase(dbPath, codec: codec);

...your database is ready to use

Implementation

SembastCodec getEncryptSembastCodecSalsa20({required String password}) =>
    SembastCodec(
        signature: _encryptCodecSignature,
        codec: _EncryptCodec(_generateEncryptPassword(password)));