# Hash

## Hash

[HASH functions video](https://www.youtube.com/watch?v=tLkHk__-M6Q\&index=20\&list=PL6N5qY2nvvJE8X75VkXglSrVhLv1tVcfy)

#### Security

```
Symmetric  |   ECC   |  DH/DSA/RSA  | HASH
-----------+---------+--------------+-----
    80     |   163   |     1024     | 160 
   112     |   233   |     2048     | 224
   128     |   283   |     3072     | 256
   192     |   409   |     7680     | 384
   256     |   571   |    15360     | 512

            Comparable Key Sizes (in bits)
```

### SHA3

[spec](https://csrc.nist.gov/projects/hash-functions/sha-3-project)

Descriptopn: It is the latest member of the Secure Hash Algorithm family of standards, released by NIST.

Outputs: 512, 384, 256, 224.

Uses: General propuse, 3GPP TS 35.231, FIPS 202 , SP 800-185. TUAK, NIST, FIPS.

### SHA2 & SHA1

[spec](https://csrc.nist.gov/publications/detail/fips/180/4/final)

[SHA1 video](https://www.youtube.com/watch?v=JIhZWgJA-9o\&index=21\&list=PL6N5qY2nvvJE8X75VkXglSrVhLv1tVcfy)

Description: NSA cryptographic hash functions.

Outputs: SHA2: 512, 384, 256, 224. SHA1: 160

Uses: General propuse, backward compatibility. NIST, FIPS.

### Whirlpool

\[spec]\(<https://en.wikipedia.org/wiki/Whirlpool_(cryptography>))

Description: Hash based on AES.

Outputs: 512

Uses: Performance is not impportant, ISO/IEC 10118-3, NESSIE, ISO ,IEC.

### Blake2b

[spec](https://blake2.net/)

Description: Faster hash than SHA-3, SHA2, SHA1, MD5 and at least as secure as the latest standard SHA-3.

Outputs: 512

Uses: Performance is impportant, RFC 7693,

### SipHash

[spec](https://131002.net/siphash/siphash.pdf)

Description: SipHash is a family of pseudorandom functions (a.k.a. keyed hash functions) optimized for speed on short messages.Target applications include network traffic authentication and defense against hash-flooding DoS attacks.

Outputs: 128

## How to ???

```python
#!/usr/bin/env python

import requests
import json
import os,binascii

def sending(message):
    url = 'http://127.0.0.1:6613/'
    response=requests.post(url, data=message)
    print response.content

data_js='{"version":1,"algorithm":"SHA3_512","type":"string","plaintext":"Hello world!"}'
sending(data_js)
```

In this example we get SHA3*512 for \_Hello world!* string

* On *data\_js\["algorithm"]* can be one of *{SHA3\_512, SHA3\_384, SHA3\_256, SHA3\_224, SHA\_512, SHA\_384, SHA\_256, SHA\_224, SHA\_1, WHIRLPOOL, BLAKE2B, SIPHASH}*

```python
data_js='{"version":1,"algorithm":"WHIRLPOOL","type":"string","plaintext":"48656c6c6f20776f726c64210d0a0d0a","hex":1}'
```

In this example We get WHIRLPOOL for *48656c6c6f20776f726c64210d0a0d0* string.

* *"hex":1* indicates the string is a hex string
* *"hex":0* indicates the string is a ascii string
* When hex doesn't appear indicates the same as *"hex":0*
* *hex* parameter only applies for when *"type":"string"*
* *hex* parameter indicates if the string is hex or ascii.

```python
data_js='{"version":1,"algorithm":"SHA_1","type":"file","file":"mayhem.txt"}'
```

In this example we get SHA*1 for \_mayhem.txt* file

* On *"type":"file"* the parameter *"hex"* isn't needed
* On *"file":"route to file"* indicates where is the file. It depends on where Coherence is running.
* On *data\_js\["type"]* can be *file* or *string*&#x20;
* *type* indicates if you are going to apply the algorithm on a file or on a string.

Json to hash string

```javascript
{"version":1,"algorithm":" hash flavor","type":"string","plaintext":"your string", "hex":BOOL}
```

Json to hash file

```javascript
{"version":1,"algorithm":"hash flavor","type":"file","file":"your file"}
```


---

# 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://coherence.3vidence.com/hash.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.
