Encryption API
Aidbox can encrypt attributes with the type secret.

Configure Devbox

Let's generate a key
1
POST /$encrypt-key
2
3
# 200
4
# 00055DDDF7BB2A52C21651283F346C048C8470CAE2796A2A2346994A05DA760B
Copied!
Copy this key into the box ENV variables and restart devbox:
1
AIDBOX_ENCRYPT_KEY="00055DDDF7BB2A52C21651283F346C048C8470CAE2796A2A2346994A05DA760B"
Copied!

Demo

Register a custom resource with the secret attribute:
1
POST /App
2
3
id: cards
4
type: app
5
apiVersion: 1
6
entities:
7
MyCard:
8
attrs:
9
name: {type: string}
10
number: {type: secret}
Copied!
Create an instance of the resource:
1
POST /MyCard
2
3
id: c1
4
number: x777888
5
name: Nikolai
6
7
# 200
8
id: c1
9
name: Nikolai
10
number: $58B5........5766D
Copied!
Read the instance with an encrypted attribute:
1
GET /MyCard/c1
2
3
# 200
4
id: c1
5
name: Nikolai
6
number: $58B5........5766D
Copied!
Decrypt the instance:
1
GET /$decrypt/MyCard/c1
2
3
id: c1
4
name: Nikolai
5
number: x777888
Copied!
Copy link