> For the complete documentation index, see [llms.txt](https://docs.ask.edvard.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ask.edvard.dev/security/hashing.md).

# Hashing

Hash sensitive information like passwords and email addresses.

Hashing is the practise of converting data into another format to secure or hide it. Hashing is done by hashing algorithms that are mathematically designed to be one-way, meaning it’s hard to decode back to the original format without some sort of key for example.

Ask’s built-in hashing solution uses sha256 encryption. SHA256 turns a given string into a 256 character long string.

Use the `hash` object for this.

## `hash()`

Returns the given value enypted by the SHA256 algorithm.

### Usage

```python
hash.hash([value])
```

### Parameters:

{% tabs %}
{% tab title="Value" %}

* Typically a string.
  {% endtab %}
  {% endtabs %}

## `check()`

Check if a value corresponds with a hash. Used for e.g. verifying passwords. Returns True/False.

### Usage

```python
hash.check([hash], [value])
```

### Parameters:

{% tabs %}
{% tab title="Hash" %}

* A SHA256 encrypted value.
  {% endtab %}

{% tab title="Value" %}

* The value to compare.
* This will e.g. be the user-submitted plain text password your verifying with the one stored in the database that has been hashed.
  {% endtab %}
  {% endtabs %}

This function only helps you save a bit of typing. Technically you could just do:

```python
if hash_string == hash.hash(’not hashed’):
    # True
    ...
else:
    # False
    ...
```

But using `.check` is a bit easier to both read and write.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.ask.edvard.dev/security/hashing.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
