# Stream-ciphers

## eStream

[eStream project](http://www.ecrypt.eu.org/stream/index.html)

[Stream ciphers video - 1 ](https://www.youtube.com/watch?v=AELVJL0axRs\&index=3\&list=PL6N5qY2nvvJE8X75VkXglSrVhLv1tVcfy)

[Stream ciphers video - 2 ](https://www.youtube.com/watch?v=sKUhFpVxNWc\&index=4\&list=PL6N5qY2nvvJE8X75VkXglSrVhLv1tVcfy)

In order to understand *hex* and *type* parameters read [HASH](https://github.com/liesware/coherence/wiki/Hash)

### Sosemanuk

[spec](http://www.ecrypt.eu.org/stream/sosemanukpf.html)

Description: Stream cipher and eStream winner.

Uses: Performance is very impportant.

Key size: from 128 to 256 bits, guaranteed security is only 128 bits.

Iv size: 128 bits

### Salsa20

[spec](http://www.ecrypt.eu.org/stream/salsa20pf.html)

Description: Stream cipher and eStream winner.

Uses: Performance is very impportant.

Key size: varibale

Iv size: 64 bits

## How to ???

```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
    return response.content

def stream(data_js):
    req=json.loads(data_js)
    print "Sosemanuk enc \n " + json.dumps(req) +"\n"
    data_js_n=sending(json.dumps(req))
    answ=json.loads(data_js_n)
    print "Recived enc: \n" + (json.dumps(answ)) +"\n\n\n"
    dec='{"algorithm":"SOSEMANUK","plaintext":"","iv":"b05691ef92cb9c9bf77e5613819fc4ea",\
    "version":1,"key":"7f685ba92789f0d8d421038f2b1b4fcd73be586d81795ec3ab7939975b7b896e","operation":"dec","type":"string"}'
    req=json.loads(dec)
    req["plaintext"]=answ["result"]
    print "Sosemanuk dec \n " + json.dumps(req) +"\n"
    data_js_n=sending(json.dumps(req))
    answ2=json.loads(data_js_n)
    print "Recived dec: \n" + (json.dumps(answ2)) +"\n\n\n"

data_js='{"algorithm":"SOSEMANUK","plaintext":"Hello world!","hex":0,"iv":"b05691ef92cb9c9bf77e5613819fc4ea",\
"version":1,"key":"7f685ba92789f0d8d421038f2b1b4fcd73be586d81795ec3ab7939975b7b896e","operation":"enc","type":"string"}'
stream(data_js)
```

In this example we encrypt and decrypt *Hello world!* string with the key and iv given

On *data\_js\["algorithm"]* can be *SOSEMANUK* or *SALSA20*

Json to enc string (key and iv depends on algorithm you chose)

```javascript
{"algorithm":"estream flavor","plaintext":"your string","hex": BOOL,"iv":"Hex stringsize=16,32",
"version":1,"key":"Hex stringsize=32-64","operation":"enc","type":"string"}
```

Json to dec string (key and iv depends on algorithm you chose)

```javascript
{"algorithm":"estream flavor","plaintext":"your hex enc string ","iv":"Hex stringsize=16,32",
"version":1,"key":"Hex stringsize=32-64","operation":"dec","type":"string"}
```

Json to enc file (key and iv depends on algorithm you chose)

```javascript
{"algorithm":"estream flavor","file":"your file","iv":"Hex stringsize=16,32",
"version":1,"key":"Hex stringsize=32-64","operation":"enc","type":"file"}
```

Json to dec file (key and iv depends on algorithm you chose)

```javascript
{"algorithm":"estream flavor","file":"your file","iv":"Hex stringsize=16,32",
"version":1,"key":"Hex stringsize=32-64","operation":"dec","type":"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/stream-ciphers.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.
