Puedes cifrar el archivo Realm en el disco con AES-256 + SHA-2 proporcionando una llave de cifrado de 64 bytes al abrir un realm.
Realm cifra y descifra datos de forma transparente con estándares Cifrado AES-256Utilizando los primeros 256 bits de la clave de cifrado de bits 512dada. Realm utiliza los otros 256 bits de la 512clave de cifrado de bits para validar la integridad mediante un código de autenticación de mensajes basado en hash (HMAC).
Advertencia
Do not use cryptographically-weak hashes for realm encryption keys. For optimal security, we recommend generating random rather than derived encryption keys.
Nota
Encripta un Realm al abrir o copia un Realm sin cifrar
You must encrypt a realm the first time you open it. If you try to open an existing unencrypted realm using a configuration that contains an encryption key, Realm throws an error.
Si no, puedes copiar los datos del realm no cifrados a un nuevo realm cifrado usando la función Realm.writeCopyTo() método. Consulta Copiar datos y abrir un nuevo Realm para obtener más información.
The following code demonstrates how to generate an encryption key and open an encrypted realm:
// Retrieve encryption key from secure location or create one const encryptionKey = new ArrayBuffer(64); // Use encryption key in realm configuration const config = { schema: [Task], encryptionKey: encryptionKey, }; const realm = await Realm.open(config);
// Retrieve encryption key from secure location or create one const encryptionKey = new ArrayBuffer(64); // Use encryption key in realm configuration const config: Configuration = { schema: [Task], encryptionKey: encryptionKey, }; const realm = await Realm.open(config);
Almacenar y reutilizar claves
You must pass the same encryption key every time you open the encrypted realm. If you don't provide a key or specify the wrong key for an encrypted realm, the Realm SDK throws an error.
Apps should store the encryption key securely, typically in the target platform's secure key/value storage, so that other apps cannot read the key.
Impacto en el rendimiento
Las lecturas y escrituras en los "realms" cifrados pueden ser hasta un 10% más lentas que en los "realms" sin cifrar.
Encryption and Atlas Device Sync
Puede encriptar un realm sincronizado.
Realm only encrypts the data on the device and stores the data unencrypted in your Atlas data source. Any users with authorized access to the Atlas data source can read the data, but the following still applies:
Users must have the correct read permissions to read the synced data.
Data stored in Atlas is always encrypted at a volume (disk) level.
The transfer between client and server is always fully encrypted.
You can also enable Customer Key Management to encrypt stored Atlas data using your cloud provider's key (e.g. AWS KMS, Azure Key Vault, Google Cloud KMS).
If you need unique keys for each user of your application, you can use an OAuth provider or use one of the Realm authentication providers and an authentication trigger to create a 64-bit key and store that key in a user object.
Access an Encrypted Realm from Multiple Processes
Cambiado en la versión realm@11.8.0.
A partir de la versión v11.8.0 del SDK de Realm Node.js, Realm admite la apertura del mismo reino cifrado en múltiples procesos.
Si tu aplicación utiliza Realm Node.js SDK versión v11.7.0 o anterior, intentar abrir un Realm cifrado desde múltiples procesos genera este error:
Encrypted interprocess sharing is currently unsupported.
Cifrar metadatos de la aplicación de App Services
If you use Atlas Device Sync with your realm, your App Services App uses an on-device metadata file to determine changes that should sync.
You can encrypt this metadata file in a similar manner as encrypting your realm.
Para obtener más información, consulta Cifrar metadatos de la aplicación.