# Cryptography

## Overview

This section contains recommendations for implementing and using functionality related to cryptographic operations.

{% hint style="warning" %}
Main rule of cryptography is do **not** invent your own cryptography. It can definitely be hacked.
{% endhint %}

## General practices

| Scenario              | Algorithm (base)                      | Algorithm (advanced)                     |
| --------------------- | ------------------------------------- | ---------------------------------------- |
| Key exchange          | Diffie-Hellman key exchange, 2048 bit | ECDH Curve25519                          |
| Message integrity     | HMAC-SHA2, 256 bit                    | HMAC-SHA2, 512 bit                       |
| Message hash          | SHA2, 256 bit                         | SHA2, 512 bit                            |
| Asymmetric encryption | RSA, 2048 bit, SHA-256                | ECC Curve25519 or RSA, 3072 bit, SHA-256 |
| Symmetric encryption  | AES, 128 bit, GCM                     | AES, 256 bit, GCM                        |
| Key exchange          | Argon2 or PBKDF2                      | Argon2 or PBKDF2                         |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://0xn3va.gitbook.io/application-security-handbook/web-application/cryptography.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
