Reading Encrypted Arrays

To read from an encrypted array, you simply need to open it for reading using the encryption key you used to create it.

C
C++
Python
R
Java
Go
C
// ... create context ctx
// Open encrypted array for reading
const char key[] = "0123456789abcdeF0123456789abcdeF";
tiledb_array_t* array;
tiledb_array_alloc(ctx, "<array-uri>", &array);
tiledb_array_open_with_key(
ctx, array, TILEDB_READ, TILEDB_AES_256_GCM, key, sizeof(key));
// Or, open at timestamp
unsigned long long timestamp = 1561492235844; // In ms
tiledb_array_open_at_with_key(
ctx, array, TILEDB_READ, TILEDB_AES_256_GCM, key, sizeof(key), timestamp);
C++
// ... create context ctx
// Open encrypted array for reading
const char key[] = "0123456789abcdeF0123456789abcdeF";
Array array(ctx, "<array-uri>", TILEDB_READ, TILEDB_AES_256_GCM, key, sizeof(key));
// Or, open at timestamp
uint64_t timestamp = 1561492235844; // In ms
Array array(ctx, "<array-uri>", TILEDB_READ, TILEDB_AES_256_GCM, key, sizeof(key), timestamp);
Python
# All array and schema opening APIs support `key` as an
# optional keyword argument to open encrypted arrays:
key = "0123456789abcdeF0123456789abcdeF"
tiledb.DenseArray(uri, key=key)
tiledb.SparseArray(uri, key=key)
tiledb.open(uri, key=key)
tiledb.ArraySchema.load(uri, key=key)
R
# TODO: Encrypted arrays are not currently supported in the R API
Java
// ... create context ctx
// Open encrypted array for reading
String key = "0123456789abcdeF0123456789abcdeF";
Array array = new Array(ctx, "<array-uri>", TILEDB_READ, TILEDB_AES_256_GCM, key.getBytes(StandardCharsets.UTF_8));
// Or, open at timestamp
uint64_t timestamp = 1561492235844; // In ms
Array array = new Array(ctx, "<array-uri>", TILEDB_READ, TILEDB_AES_256_GCM, key.getBytes(StandardCharsets.UTF_8), timestamp);
Go
// ... create context ctx
// Open encrypted array for reading
var encryption_key = "0123456789abcdeF0123456789abcdeF"
array, _ := tiledb.NewArray(ctx, "<array-uri>")
array.OpenWithKey(tiledb.TILEDB_READ, tiledb.TILEDB_AES_256_GCM, encryption_key)
// Or, open at timestamp
var timestamp uint64 = 1561492235844 // In ms
array.OpenAtWithKey(tiledb.TILEDB_READ, tiledb.TILEDB_AES_256_GCM, encryption_key, timestamp)