In order to protect the data from being decrypted easily by anyone, the asymmetric encryption method is used. It’s the safest method as it requires a combination of 2 keys: Public and Private key.
Data Encryption
All data must be encrypted in order to use Controlled Exposure and/or API Troubleshooting details.
To do this, you will need to obtain a combination of encryption keys:
- Public key: is used when we collect the data so we can encrypt it
- Private key: is used in the Contentsquare Platform when displaying the data for decryption
How to generate the key pair
Option 1: With a Google chrome script (recommended)
1. Copy the following script
function arrayBufferToString(buffer) { const byteArray = new Uint8Array(buffer); let byteString = ""; for (let i = 0; i < byteArray.byteLength; i += 1) { byteString += String.fromCodePoint(byteArray[i]); } return byteString; } crypto.subtle.generateKey({ name: "RSA-OAEP", hash: "SHA-256", modulusLength: 4096, publicExponent: new Uint8Array([1,0,1]) }, true, ["encrypt", "decrypt"]).then( (keysObject) => { crypto.subtle.exportKey("pkcs8", keysObject.privateKey).then(result => { const privateKey = btoa(arrayBufferToString(result)); console.log(`Private key: `, privateKey); }); crypto.subtle.exportKey("spki", keysObject.publicKey).then(result => { const publicKey = btoa(arrayBufferToString(result)); console.log(`Public key: `,publicKey); }); });
2. Paste the script in the Chrome console
3. Press enter on the keyboard
Option 2: With OpenSSL or OpenSSH
On linux/mac, you can use openssl:
openssl genpkey -out mykey.pem -algorithm RSA -pkeyopt rsa_keygen_bits:4096
openssl rsa -in mykey.pem -pubout > mykey.pub
On windows you will need to install WSL
Install WSL
How to add a new public key
1. Click your 'profile icon', then click 'Console'.
2. Choose the account and project, then select the 'Encryption management' tab.
3. Click 'Store Public key'.
4. Paste your preferred public key.
5. Click 'Store Key'.
How to replace a key
1. Click your 'profile icon', then click 'Console'.
2. Choose the account and project, then select the 'Encryption management' tab.
3. Click 'Replace with a new key'.
4. Enter in the new key and click 'Replace key'.