Encrypt data¶
Encrypts a string, a number, an object or an array and answers the encrypted text. By default it uses encryptionAlgorithmFETransfer and secretFETransfer of the default secret : the key you share with your frontend or mobile app, so the two sides can exchange encrypted data.
| Method | POST |
| URL | /api/system-api/admin/encrypt-data : admin is the user path of your account |
| Body | { data, algorithm?, pass? } |
| Answer | data : the encrypted string |
| From code | g.sys.system.encrypt |
The call¶
Answer
{ "success": true, "statusCode": 200, "data": "U2FsdGVkX19iIBA3FQy3OgFXeE4B2cC8lAfaJjCbMmUllceqb58YwvQqU33PkQEQ" }
| Key | Meaning |
|---|---|
data |
Required. Any JSON value. It is serialised before encryption, so decrypt gives the same type back. |
algorithm |
AES (default from the secret). RC4 and TRIPLEDES are legacy ciphers, kept for the data of API Maker 3. |
pass |
Your own key, instead of secretFETransfer of the secret. |
- The keys come from the default secret of the account, unless the body gives its own
algorithmandpass.
From code¶
Good to know¶
- Fields of a table are encrypted at rest with
conversions: { encryption: true }in the schema, with thesecretkey of the secret, not this API. - To send an encrypted request body, see encrypted payloads ; to get an encrypted answer, the header
x-am-get-encrypted-data.
An unknown algorithm answers 400, and the message names it.
Access, headers and errors¶
- Over HTTP, a system API answers only once its settings open it :
TOKEN_ACCESS(the token of an API user whose group grants this system API) orIS_PUBLIC. Without settings it isNO_ACCESS: only your code (g.sys) and the admin panel reach it. - The settings can also keep the answer in the cache, or ask for the token of a person (
authProviders). Pre and post hooks run around it, as around any API. - It takes the request headers and answers the envelope.
401: no valid token, or the API isNO_ACCESS.403: no group grants it.400: the body is wrong, and the message names the key.
Related : All APIs · System API settings · System APIs from code