Skip to content

Commit

Permalink
Add note to all SDKs
Browse files Browse the repository at this point in the history
  • Loading branch information
cbullinger committed Nov 13, 2023
1 parent 3234f41 commit 0413956
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 9 deletions.
8 changes: 8 additions & 0 deletions source/sdk/dotnet/realm-files/encrypt-a-realm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ integrity using a :wikipedia:`hash-based message authentication code

.. include:: /includes/encrypt-use-strong-cryptographic-hash.rst

.. note:: Cannot Encrypt an Existing Unencrypted Realm

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.

.. update with writeCopy API when available

Considerations
--------------

Expand Down
11 changes: 11 additions & 0 deletions source/sdk/flutter/realm-database/realm-files/encrypt.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ integrity using a :wikipedia:`hash-based message authentication code

.. include:: /includes/encrypt-use-strong-cryptographic-hash.rst

.. note:: Encrypt a Realm on Open or Copy Unencrypted Realm

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.

Alternatively, you can copy the unencrypted realm data to a new
encrypted realm using the
:flutter-sdk:`Realm.writeCopy() <realm/Realm/writeCopy.html>` method.
Refer to :ref:`<flutter-copy-data-into-new-realm>` for more information.

Considerations
--------------

Expand Down
34 changes: 25 additions & 9 deletions source/sdk/kotlin/realm-database/realm-files/encrypt-a-realm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Encrypt a Realm - Kotlin SDK

You can encrypt your realms to ensure that the data stored to disk can't be
read outside of your application. You encrypt the realm file on
disk with AES-256 + SHA-2 by supplying a 64-byte encryption key when
:ref:`opening the realm <kotlin-open-and-close-a-realm>`.
disk with AES-256 + SHA-2 by supplying a 64-byte encryption key when first
:ref:`opening the realm <kotlin-open-and-close-a-realm>`.

Realm transparently encrypts and decrypts data with standard
:wikipedia:`AES-256 encryption <Advanced_Encryption_Standard>` using the
Expand All @@ -24,13 +24,26 @@ integrity using a :wikipedia:`hash-based message authentication code

.. include:: /includes/encrypt-use-strong-cryptographic-hash.rst

.. note:: Encrypt a Realm on Open or Copy Unencrypted Realm

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.

Alternatively, you can copy the unencrypted realm data to a new
encrypted realm using the
`Realm.writeCopyTo() <{+kotlin-local-prefix+}io.realm.kotlin/-realm/write-copy-to.html>`__
method.
Refer to :ref:`<kotlin-copy-data-to-realm>` for more information.

Encrypt a Local Realm
---------------------

To encrypt a local realm, pass your encryption key to the
`encryptionKey <{+kotlin-local-prefix+}io.realm.kotlin/-configuration/encryption-key.html>`__
property in your
`RealmConfiguration.Builder() <{+kotlin-local-prefix+}io.realm.kotlin/-realm-configuration/index.html>`__.
property in the
`RealmConfiguration.Builder() <{+kotlin-local-prefix+}io.realm.kotlin/-realm-configuration/index.html>`__
used to open the realm.

The following code demonstrates how to generate an encryption key and
open an encrypted local realm:
Expand All @@ -44,21 +57,24 @@ open an encrypted local realm:
Encrypt a Synced Realm
----------------------

You can encrypt a :ref:`synced realm <kotlin-open-a-synced-realm>`, similar
If your app uses Atlas Device Sync, you can encrypt a synced realm, similar
to encrypting a local realm.

To encrypt a synced realm, pass your encryption key to the
`encryptionKey <{+kotlin-sync-prefix+}io.realm.kotlin.mongodb/-app-configuration/encryption-key.html>`__
property in your
property in the
`SyncConfiguration.Builder()
<{+kotlin-sync-prefix+}io.realm.kotlin.mongodb.sync/-sync-configuration/-builder/-builder.html>`__.
<{+kotlin-sync-prefix+}io.realm.kotlin.mongodb.sync/-sync-configuration/-builder/-builder.html>`__
used to open the realm.

The following code demonstrates how to open an encrypted synced realm:

.. literalinclude:: /examples/generated/kotlin/EncryptARealmTest.snippet.encrypt-synced-realm.kt
:language: kotlin
:emphasize-lines: 5-6

Refer to :ref:`<kotlin-open-a-synced-realm>` for more information.

Encryption and Atlas Device Sync
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -97,8 +113,8 @@ Performance Impact

Reads and writes on encrypted realms can be up to 10% slower than unencrypted realms.

Access Encrypted Realm from Multiple Processes
----------------------------------------------
Access Encrypted Realms from Multiple Processes
-----------------------------------------------

.. versionchanged:: 10.8.0

Expand Down
13 changes: 13 additions & 0 deletions source/sdk/node/realm-files/encrypt.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ integrity using a :wikipedia:`hash-based message authentication code

.. include:: /includes/encrypt-use-strong-cryptographic-hash.rst

.. note:: Encrypt a Realm on Open or Copy Unencrypted Realm

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.

Alternatively, you can copy the unencrypted realm data to a new
encrypted realm using the
:js-sdk:`Realm.writeCopyTo() <Realm.html#writeCopyTo>`
method.
Refer to :ref:`<node-open-existing-realm-different-configuration>`
for more information.

The following code demonstrates how to generate an encryption key and
open an encrypted realm:

Expand Down
8 changes: 8 additions & 0 deletions source/sdk/react-native/realm-files/encrypt.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ integrity using a :wikipedia:`hash-based message authentication code

.. include:: /includes/encrypt-use-strong-cryptographic-hash.rst

.. note:: Cannot Encrypt an Existing Unencrypted Realm

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.

.. update with writeCopy API info once available

The following code demonstrates how to generate an encryption key and
open an encrypted realm:

Expand Down
8 changes: 8 additions & 0 deletions source/sdk/swift/realm-files/encrypt-a-realm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ integrity using a :wikipedia:`hash-based message authentication code

.. include:: /includes/encrypt-use-strong-cryptographic-hash.rst

.. note:: Cannot Encrypt an Existing Unencrypted Realm

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.

.. update with writeCopy API when available

Considerations
--------------

Expand Down

0 comments on commit 0413956

Please sign in to comment.