# Криптография

Ниже описаны криптографические функции.

* [AESDecrypt( str key, buf data ) buf](/stdlib/crypto.md#aesdecrypt-str-key-buf-data-buf)
* [AESEncrypt( str key, buf data ) buf](/stdlib/crypto.md#aesencrypt-str-key-buf-data-buf)
* [Md5( buf | str data ) buf](/stdlib/crypto.md#md-5-buf-or-str-data-buf)
* [RandomBuf( int size ) buf](/stdlib/crypto.md#randombuf-int-size-buf)
* [Sha256( buf | str data ) buf](/stdlib/crypto.md#sha-256-buf-or-str-data-buf)

## Функции

### AESDecrypt( str key, buf data ) buf

Функция *AESDecrypt* расшифровывает содержимое переменной типа *buf* с использованием ключа шифрования *key*. Зашифрованные данные должны быть получены с помощью функции *AESEncrypt*. Функция возвращает переменную типа *buf* с расшифрованными данными.

```go
buf encrypted = AESDecrypt(`my password`, encrypted)
```

### AESEncrypt( str key, buf data ) buf

Функция *AESEncrypt* шифрует содержимое переменной типа *buf* используя алгоритм AES-256. Параметр *key* является ключом шифрования. Функция возвращает переменную типа *buf* с зашифрованными данными. Используйте функцию *AESDecrypt* для расшифровки данных.

```go
buf crypted = AESEncrypt(`my password`, buf(`Test message`))
```

### Md5(buf|str data) buf

Функция *Md5* возвращает MD5 хэш переменной типа *buf* или *str*.

### RandomBuf(int size) buf

Функция *RandomBuf* возвращает переменную типа *buf*, которая содержит последовательность случайных байт указанного размера.

### Sha256(buf|str data) buf

Функция *Sha256* возвращает SHA256 хэш переменной типа *buf* или *str*.


---

# 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://ru.gentee.org/stdlib/crypto.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.
