Your task is to implement a REST API which:
-
Has two endpoints
/encrypt
and/decrypt
. Each endpoint should take a JSON payload. -
Use Base64 to implement encryption and decryption on the
/encrypt
and/decrypt
endpoints respectively./encrypt
should encrypt every value in the object (at a depth of 1), returning the encrypted payload as JSON./decrypt
should detect encrypted strings and decrypt them, returning the decrypted payload as JSON.
For example:
{ "foo": "foobar", "bar": { "isBar": true } }
would become
{ "foo": "some_encrypted_string", "bar": "some_encrypted_string" }
-
The Base64 encryption algorithm should be easily replaceable with another algorithm without requiring significant changes to the codebase.
-
Create a
/sign
endpoint which takes a JSON payload and computes a cryptographic signature for the plaintext payload in HMAC. The signature is then sent in a JSON response. -
Create a
/verify
endpoint, which takes a JSON payload of the form
{
"signature": "<COMPUTED_SIGNATURE>",
"data": {
// ...
}
}
- Data can be any JSON object.
- If the provided signature matches the computed signature, the response code should be
204
; otherwise, it should be400
.
Send me the project, your GitHub repository by email [email protected].