Creating Encrypted Arrays

In order to create an encrypted array, you simply need to pass your secret key upon the array creation:

C
C++
Python
R
Java
Go
C
#include <tiledb/tiledb.h>
// ... create context ctx
// ... create array schema
const char encryption_key[] = "0123456789abcdeF0123456789abcdeF";
// Create the array
tiledb_array_create_with_key(
ctx,
"<array_uri>",
schema,
TILEDB_AES_256_GCM,
encryption_key,
(uint32_t)strlen(encryption_key));
C++
#include <tiledb/tiledb>
// ... create array schema
const char encryption_key[] = "0123456789abcdeF0123456789abcdeF"
// Create the array
Array::create(
array_name,
"<array_uri>",
TILEDB_AES_256_GCM,
encryption_key,
(uint32_t)strlen(encryption_key));
Python
import tiledb
import numpy as np
# ... create array schema
key = "0123456789abcdeF0123456789abcdeF"
# Create a dense array with a key
tiledb.DenseArray.create("<array_uri>", schema, key=key)
# Create a sparse array with a key
tiledb.SparseArray.create("<array_uri>", schema, key=key)
R
# shortcut: borrow schema from dense array
# could create new schema here too
sch <- schema(tiledb_dense(uridense))
# create encrypted array
tiledb:::libtiledb_array_create_with_key(uriec,
sch@ptr,
encryption_key)
Java
// ... create array schema
String key = "0123456789abcdeF0123456789abcdeF";
// Create the array
Array.create("my_array",
schema,
TILEDB_AES_256_GCM,
key.getBytes(StandardCharsets.UTF_8));
Go
// ... create context ctx
// ... create schema
var encryption_key = "0123456789abcdeF0123456789abcdeF"
// Create the array
array, err := tiledb.NewArray(ctx, "<array_uri>")
array.CreateWithKey(schema, tiledb.TILEDB_AES_256_GCM, encryption_key)