Cryptography-API

Cryptography-API

Dr.Caduceus

Welcome to the Documentation of Cryptography-API 🔐

🌐API Root:
cryptography.thecaduceus.eu.org

🔒Encryption:

POST a JSON to /encrypt in json format with a string key whose value is equal to the string which needs to be encrypted.

Input:

{
  "string": "Hello World!"
}

Response:

{
  "error": "false",
  "result": "gAAAAABjp_tq2a_MRpQA-QElQ2iughLdW1U74WbP1-Ls0lNV3pM93hrbJUopT86f19C0PVVVY8W5iYXGgeUHkphh_l-OgWMJVQ=="
}

In above example, the given string will be encrypted using a default decryption key and can be decrypted using the same.

While to make it impossible for any encrypted string be decrypted using default decryption key, a custom decryption key must be passed using decrypt_key as a key.

Value of decrypt_key must be 32 url-safe base64-encoded bytes and should be pasted as str.

Input:

{
  "string":"Hello World!",
  "decrypt_key":"beleSmjbYP_ZBVCPRZUGdIfb9-U7cqkkXqFn9qyEgY4="
}

Response:

{
  "error":"false",
  "result":"gAAAAABjp_4MPgHLRbwpwOCdsJo2KwEx2yeODX0wW9hyQ
FLavGhileSp1qSZmEzQERNFXT1-_jAYwaOdZZ_g0IZon-DGVPa_5w=="
}

Users can also ask API to encrypt the given string using a random decrypt_key other than default decrypt_key, to do this we have to pass the value of decrypt_key as "random" in our input. In response, the API will also return the decrypt_key which was used to encrypt your given string.

Input:

{
  "string":"Hello World!",
  "decrypt_key":"random"
}

Response:

{
  "error":"false",
  "result":"gAAAAABjqRjGMOEy6YKn7QIVaj9sh5m3R
KQsOJcMwkCtgbxMKHBbzVrCt4u-pwhRfLlBFt60gcSuL0Z01TTjQ6TGUF_CPZMvxA==",
  "decrypt_key":"-XIQZer8S7n9XKqm-r5xl9g3BFw1TwutehIia45y9e0="
}

⚙️Key Generation:

In Python, own decrypt_key can be easily generated by running following code:

import requests

key = requests.get('https://cryptography.thecaduceus.eu.org/newkey').json()

print(key)

🔓Decryption:

POST a JSON to /decrypt in json format with a string key whose value is equal to the encrypted string which needs to be decrypted.

Input:

{
  "string":"gAAAAABjp_tq2a_MRpQA-QElQ2iughLdW1U74WbP1-Ls0lNV3pM93hrbJUopT86f19C0PVVVY8W5iYXGgeUHkphh_l-OgWMJVQ==
"
}

Response:

{
  "error":"false",
  "result":"Hello World!"
}

In above example, the given encrypted string will be decrypted using a default decrypt_key.

While if the given string is encrypted using a decrypt_key other than the default one, then it becomes compulsory to provide the decrypt_key which was used to encrypt the string.

Input:

{
  "string":"gAAAAABjp_4MPgHLRbwpwOCdsJo2KwEx2yeODX0wW9hyQ
FLavGhileSp1qSZmEzQERNFXT1-_jAYwaOdZZ_g0IZon-DGVPa_5w==",
  "decrypt_key":"beleSmjbYP_ZBVCPRZUGdIfb9-U7cqkkXqFn9qyEgY4="
}

Response:

{
  "error":"false",
  "result":"Hello World!"
}

❓FAQ:

What about strings and decryption keys? they are being logged/saved somewhere? 🤔

No, the given API only processes strings & decryption keys to provide required output and never store/log it anywhere.

What if I lose my decryption keys? is it can be recovered? 😣

Sorry, in that case the encrypted string can't be decrypted, and its lost decryption key can't be recovered because as stated above the keys are not stored anywhere.

Is this API can be implemented with all languages? ✅

Yes, it can be easily implemented with any language which supports posting data to any particular API which is most basic task & can be done by any programming language, below you will find examples based on Python (commonly used programming language).

Does this API have any limitations? 🛡️

Yes, like any other API, Symmetric Encryption API also have limits which are there to prevent overload & spam:

Character Limit:

  • 4000 for /encrypt.
  • 550 for decrypt_key.
  • 5500 for /decrypt.

Request Limit:

  • None.

📃Example:

Following is the Python code to interact with API:

import requests

API = 'https://cryptography.thecaduceus.eu.org'

# Generate new Key
key = requests.get(f'{API}/newkey').json()['key']

# Json Data for Encryption
json_data = {"string":"Hello World!","decrypt_key": key}

# Post data to Encrypt
resp = requests.post(f'{API}/encrypt', json=json_data).json()['result']

# Show Encrypted Response
print(f'Encrypted Message:\n{resp}')
print(f'Decryption Key:\n{key}')

# Json Data for Decryption
json_data = {"string": resp, "decrypt_key": key}

# Post data to Decrypt
resp = requests.post(f'{API}/decrypt'. json=json_data).json()['result']

# Show Decrypted Response
print(f'Decrypted Message:\n{resp}')

Report Page