- Embedded
- Python SDK
- JS/TS
Copy
Ask AI
@staticmethod
generate_key(save: bool = False) -> bytes
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
save | bool | False | Whether to save/load the generated key to/from a local file |
Returns
bytes: Cryptographically secure 32-byte keyExample Usage
Copy
Ask AI
# Generate a new encryption key
index_key = CyborgVectorStore.generate_key(save=True)
print(f"Key length: {len(index_key)} bytes")
# Use the key to create a store
store = CyborgVectorStore(
index_name="secure_index",
index_key=index_key,
api_key="your-api-key",
embedding="all-MiniLM-L6-v2",
index_location=DBConfig("s3", bucket="secure-bucket"),
config_location=DBConfig("s3", bucket="secure-bucket")
)
# Store the key securely for future use
import base64
encoded_key = base64.b64encode(index_key).decode('utf-8')
print(f"Base64 encoded key: {encoded_key}")
Copy
Ask AI
@staticmethod
generate_key(save: bool = False) -> bytes
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
save | bool | False | Whether to save/load the generated key to/from a local file |
Returns
bytes: Cryptographically secure 32-byte keyExample Usage
Copy
Ask AI
index_key = CyborgVectorStore.generate_key(save=True)
store = CyborgVectorStore(
index_name="secure_index",
index_key=index_key,
api_key="your-api-key",
embedding="all-MiniLM-L6-v2",
base_url="http://localhost:8000"
)
Copy
Ask AI
static generateKey(): Uint8Array
Returns
Uint8Array: Cryptographically secure 32-byte keyThe JS/TS SDK does not have a
save parameter. Key persistence must be handled by your application. The return type is Uint8Array instead of Python’s bytes.Example Usage
Copy
Ask AI
const indexKey = CyborgVectorStore.generateKey();
console.log(`Key length: ${indexKey.length} bytes`);
const store = new CyborgVectorStore(
new OpenAIEmbeddings(),
{
baseUrl: "http://localhost:8000",
apiKey: "your-api-key",
indexName: "secure_index",
indexKey: indexKey
}
);
Security Notes
Store encryption keys securely! Never commit keys to version control or expose them in logs. Consider using a key management service for production deployments.