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 10, 2023
1 parent a5f3093 commit 28bc4cf
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 9 deletions.
7 changes: 7 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,13 @@ 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 *cannot* encrypt an existing unencrypted realm.
If you pass an encryption key to a configuration
that does not already have one, Realm throws an
error when you attempt to open the existing realm.

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

Expand Down
12 changes: 12 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,18 @@ 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 *cannot* encrypt an existing unencrypted realm.
If you pass an encryption key to a configuration
that does not already have one, Realm throws an
error when you attempt to open the existing realm.

You can copy an unencrypted realm 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
35 changes: 26 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,27 @@ 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 *cannot* encrypt an existing unencrypted realm.
If you pass an encryption key to a configuration
that does not already have one, Realm throws an
error when you attempt to open the existing realm.

Instead, 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 +58,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 +114,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
14 changes: 14 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,20 @@ 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 *cannot* encrypt an existing unencrypted realm.
If you pass an encryption key to a configuration
that does not already have one, Realm throws an
error when you attempt to open the existing realm.

You can copy an unencrypted realm 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
7 changes: 7 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,13 @@ 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 *cannot* encrypt an existing unencrypted realm.
If you pass an encryption key to a configuration
that does not already have one, Realm throws an
error when you attempt to open the existing realm.

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

Expand Down
7 changes: 7 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,13 @@ 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 *cannot* encrypt an existing unencrypted realm.
If you pass an encryption key to a configuration
that does not already have one, Realm throws an
error when you attempt to open the existing realm.

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

Expand Down

0 comments on commit 28bc4cf

Please sign in to comment.