Generating Encryption Key

You need a base64-encoded 256-bit encryption key for Unibrain

Below are examples of how to generate a base64-encoded 256-bit encryption key in a few different programming languages.

Python

import base64
import os

key = base64.b64encode(os.urandom(32)).decode('utf-8')
print(key)

JavaScript (Node.js)

const crypto = require('crypto');

const key = crypto.randomBytes(32).toString('base64');
console.log(key);

Java

import java.security.SecureRandom;
import java.util.Base64;

SecureRandom random = new SecureRandom();
byte[] key = new byte[32];
random.nextBytes(key);
String base64Key = Base64.getEncoder().encodeToString(key);
System.out.println(base64Key);

Go

Ruby

Each example generates a random 256-bit key, encoded in Base64, suitable for use in both storing context and searching context endpoints.

Last updated