> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cyborg.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Load an Existing Encrypted Index

If you've previously created an encrypted index, you can connect to it to add, query or delete data from it. You will need to know the index's name as well as its key to do so:

<CodeGroup>
  ```python Python icon="python" theme={null}
  import cyborgdb_core as cyborgdb
  import secrets

  # Using `threadsafememory` storage for this example
  index_location = cyborgdb.DBConfig("threadsafememory") 
  config_location = cyborgdb.DBConfig("threadsafememory")

  # Get your API key
  api_key = "your_api_key_here"  # Replace with your actual API key

  # Create a client
  client = cyborgdb.Client(
      api_key=api_key, 
      index_location=index_location, 
      config_location=config_location
  )

  # Provide the index key used when creating the index
  index_key = secrets.token_bytes(32)

  # Load an encrypted index
  index = client.load_index(
      index_name="my_index", 
      index_key=index_key
  )
  ```

  ```cpp C++ icon="brackets-curly" theme={null}
  #include "cyborgdb_core/client.hpp"
  #include "cyborgdb_core/encrypted_index.hpp"
  #include <array>

  // Using `threadsafememory` storage for this example
  cyborg::DBConfig index_location(cyborg::Location::kThreadSafeMemory);
  cyborg::DBConfig config_location(cyborg::Location::kThreadSafeMemory);
  cyborg::DBConfig contents_location(cyborg::Location::kThreadSafeMemory);

  // Get your API key
  std::string api_key = "your_api_key_here";  // Replace with your actual API key

  // Create a client
  cyborg::Client client(api_key, index_location, config_location, contents_location, 0, cyborg::kNone);

  // Provide the index key used when creating the index
  // Example key (32 bytes)
  std::array<uint8_t, 32> index_key;

  // Load an encrypted index
  auto index = client.LoadIndex("my_index", index_key);
  ```
</CodeGroup>

<Warning>You will need to replace `index_key` with your own index encryption key.
For production use, we recommend that you use an HSM or KMS solution.
For more details, see [Managing Encryption Keys](../advanced/managing-keys).</Warning>

## API Reference

For more information on loading an encrypted index, refer to the API reference:

<CardGroup cols={2}>
  <Card title="Python API Reference" href="../../python/client/load-index" icon="python">
    API reference for `load_index()` in Python
  </Card>

  <Card title="C++ API Reference" href="../../cpp/client/load-index" icon="brackets-curly">
    API reference for `LoadIndex()` in C++
  </Card>
</CardGroup>
